I just started to use Bryntum Siesta and ExtJs for Automated testing. My first, very simple test work like i expected. Now i came across a problem with DRY-Code.
I am trying to write DRY Code for a Login Test.
There are actually two cases here: - a Login with valid data - a login with non-valid data (wrong password AND/OR Username)
In java it would work with global variables/functions. And i thought, that i've done something like javascript global variables before. But it doesn't work.
So i have my tryout function:
var testFunction = function(){
console.log("I am a global function, and i am working!");
};
and my goal is to call it in my t.chain() in my Testfile:
{
type: LoginUsername,
target: ">>#loginviewIdemId #loginForm #pwTriggerForm #fldName",
desc: 'Type in Username',
},
function(next) {
testFunction();
next();
},
When i call a function that was created in this testfile above the chain, it does work. I am sorry if it some basic javascript question, but im getting devastated :D
Thanks in advance!
You can extend your Test class to add utility methods and avoid DRY violations. This guide post sums it up: https://www.bryntum.com/docs/siesta/#!/guide/extending_test_class
Let's create 2 special assertions, which will be checking the odd parity of a passed number. Usually, an assertion needs to check its statement and report the result with either {@link Siesta.Test#pass} or {@link Siesta.Test#fail} methods.
When failing, try to provide as much information about the failure as possible and format the failure message in a readable form. Please refer to {@link Siesta.Test#fail} method documentation for additional options.
To make the Harness use your new test class you have to specify the test class to use by setting the {@link Siesta.Harness#testClass} configuration option:
The test class should be loaded right after the siesta-all.js file:
Now you can use your custom assertion or utility methods in all your tests: