Page 1 of 1

Starting next iteration of test

Posted: Tue Feb 19, 2019 2:54 pm
by manish
Hi All,

I am running a data driven test where I have around 100 data points in the data set.
I want the testcase to wait for a certain event to occur and then decide how to proceed with testcase execution.

If(condition happens){
Stop the current iteration with a warning message and start with the next iteration.
}

How do I start the next iteration from code without throwing an error/failure and continue with next iteration?

Thank you
Manish

Re: Starting next iteration of test

Posted: Tue Feb 19, 2019 3:21 pm
by odklizec
Hi,

I think the only non-error way to do what you want is using SmartFolder(s) with condition and a code module (placed before SmartFolder with condition), which should check the test state and fill a TestCase parameter. This TC parameter would be then evaluated in SmartFolder condition.
Here is a mockup of test case structure:

Code: Select all

[TestCase] <- data connector and TC parameter e.g. 'tcState'
|_RecModule
|_RecModule
|_...
|_CodeModule <- here you should evaluate the TC state and fill 'tcState' (e.g. tcState="0" for stop, tcState="1" for continue)
|_[SmartFolder] <- condition evaluating tcState (do not run SF if tcState=="0") 
    |_RecModule
    |_RecModule
    |_RecModule
    |_...
Hope this helps?

Re: Starting next iteration of test

Posted: Wed Feb 20, 2019 9:19 am
by manish
Hi,

Thanks for the reply. This is not what I want to do. It is during the execution, that I wait for a certian element to occur (this is the wait condition) and then either continue with the test case or start with a new iteration.
I am able to do this by throwing an error and starting the next iteration but I am looking for a way in which I do not have to introduce errors.

Regards,
Manish

Re: Starting next iteration of test

Posted: Wed Feb 20, 2019 9:34 am
by odklizec
Hi,

The solution I suggested does exactly what you have described. The only problem is, that it will work only if you know EXACT place, where you want to validate an element. And from the description of your problem I understood that you know the decision point? So instead of Validate, you can use Exists() method. If element exists, you can continue with TC, otherwise, it will not run the TC. True, the solution I described will require you to modify your test workflow.

If you are looking for a 'global' solution, running above the test itself (in a separate thread), and which will check every action/element used in every recording, then I'm afraid, you are probably out of luck?

Re: Starting next iteration of test

Posted: Thu Feb 21, 2019 8:55 am
by manish
It woks if I use :
return;

inside the condition. It sopts the current iteration and moves on to the next one.

Re: Starting next iteration of test

Posted: Thu Feb 21, 2019 9:00 am
by odklizec
Hi,

You mean you simply added a condition (with return) in one of your TC recordings and it skipped next recording steps and all remaining recordings in actually running iteration (without throwing an exception) and then it started new iteration?

Re: Starting next iteration of test

Posted: Thu Feb 21, 2019 9:30 am
by manish
Hi,


I do not use recording modules for my tests. I have a bunch of code modules that I use as individual testcases. I mean 1 module corresponds to 1 testcase. In this particular case, I use the return statement to loop out of the Run() method for that particular module iteratoion and start with the next one.

My soltion looks something like this
[Test Suite] (global variables)
[Smart Folder A]
[Testcase 1] (data driven)
[User code module 1] -------> Use return; Loops out of iterationa nd continues with next iteration
[Testcase 2] (data driven)
[User code module 2] -------- Testcase executes nevertheless
...
...


Regards,
Manish

Re: Starting next iteration of test

Posted: Thu Feb 21, 2019 9:45 am
by odklizec
I see. In such particular case yes, Return is a solution. But If there would be two or more modules in one test case, it would not work, because instead of running next iteration, it would go to module2,3, etc...