Page 1 of 1

Starting Testcase by condition

Posted: Wed Oct 10, 2012 10:20 am
by Hermch
Hi,

is it possible to start a testcase from Ranorex Studio, caused by a condition?

For example, when I have a function inside a code module wich returns a bool value, can I do something like:

If function = true then
start Testcase 1
Else
start Testcase 2

Could somebody please give me a code example in VB.net if something like this is possible?

Thanks in advance

Re: Starting Testcase by condition

Posted: Wed Oct 10, 2012 11:49 am
by swmatisa
Hello,
Hermch wrote:If function = true then
start Testcase 1
Else
start Testcase 2
I do this with the following C# usercode:

Code: Select all

bool l_Test = function();
TestSuite.Current.GetTestCase("Testcase1").Checked = l_Test ;
TestSuite.Current.GetTestCase("Testcase2").Checked = !l_Test ;
Hope this helps

Re: Starting Testcase by condition

Posted: Wed Oct 10, 2012 2:05 pm
by Hermch
Thanks for your response.

I think this code does not exactly what I want to do.
I need something that checks a conditions, depanding on this condition Testcase 1 or Testcase 2 should start, right after checking the condition.

Is this possible?

Re: Starting Testcase by condition

Posted: Wed Oct 10, 2012 2:16 pm
by swmatisa
Hermch wrote:I need something that checks a conditions, depanding on this condition Testcase 1 or Testcase 2 should start, right after checking the condition.

Is this possible?
In my code I have TestCaseCheck(a Record Module with a userCode with the "Testcase selection")
and TestCase1 and Testcase2 just after. I think it will do what you need.

Re: Starting Testcase by condition

Posted: Tue Oct 16, 2012 7:55 am
by Hermch
Hmm this does not work with my tests.

Nothing happens after this code is executed:

Code: Select all

TestSuite.Current.GetTestCase("Test_1").Checked = True
I want that "Test_1" is executed when this code is running.
How can I achieve that?

Re: Starting Testcase by condition

Posted: Tue Oct 16, 2012 1:49 pm
by swmatisa
Hello,

I create a little solution to show you the principle. It write in the log if the testId (from connector) is odd or even:
TestCaseSelection.zip

Re: Starting Testcase by condition

Posted: Wed Oct 17, 2012 8:46 am
by Hermch
Great, thank you :D