Get help with testing, discuss unit testing strategies etc.


Post by pshu »

Siesta-test: I made a new UseThis.js file, inside with a class. This class has several static method. These usually starts like:
static doSth(t,input){
t.chain(...)....}. It clicks on button, writes some text into the input area and clicks on save. Then need to repeat this n times.

My question is: how could I call this method from an outsider class precisely n times? Important to wait the end of the first before the second starts and so on.

Update:
I've tried:
t.it('ExampleTest',function(t){
for(var n=0;n<3;n++){ //console.log(n);
// if(n===3){n=0;}
UseThis.doSth(t,input[n]);
}
});

It opens the form and writes all n data to it... saves only once, but should n times!

Also tried inside of t.it()...:
UseThis.doSth(t,input[0]);
UseThis.doSth(t,input[1]);... the same.

What am I doing wrong? Could You help me? Thank you.

p.s.= and when i start test, the value of n goes to 3 immediately - this makes index problems, why does it run before it should?

Post by nickolay »

Hi,

This is a generic JavaScript question, sorry, we can't help you here. Note, that "t.chain()" is a asynchronous call, you need to provide a callback to the "doSt" method (and use it in the chain) to be notified, when the "t.chain()" call actually completes.

Post Reply