Starting Testcase by condition

Class library usage, coding and language questions.
Hermch
Posts: 40
Joined: Thu May 26, 2011 7:17 am
Location: Germany

Starting Testcase by condition

Post by Hermch » Wed Oct 10, 2012 10:20 am

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

swmatisa
Posts: 122
Joined: Fri Aug 05, 2011 7:52 am

Re: Starting Testcase by condition

Post by swmatisa » Wed Oct 10, 2012 11:49 am

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
SW

Hermch
Posts: 40
Joined: Thu May 26, 2011 7:17 am
Location: Germany

Re: Starting Testcase by condition

Post by Hermch » Wed Oct 10, 2012 2:05 pm

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?

swmatisa
Posts: 122
Joined: Fri Aug 05, 2011 7:52 am

Re: Starting Testcase by condition

Post by swmatisa » Wed Oct 10, 2012 2:16 pm

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.
SW

Hermch
Posts: 40
Joined: Thu May 26, 2011 7:17 am
Location: Germany

Re: Starting Testcase by condition

Post by Hermch » Tue Oct 16, 2012 7:55 am

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?

swmatisa
Posts: 122
Joined: Fri Aug 05, 2011 7:52 am

Re: Starting Testcase by condition

Post by swmatisa » Tue Oct 16, 2012 1:49 pm

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
You do not have the required permissions to view the files attached to this post.
SW

Hermch
Posts: 40
Joined: Thu May 26, 2011 7:17 am
Location: Germany

Re: Starting Testcase by condition

Post by Hermch » Wed Oct 17, 2012 8:46 am

Great, thank you :D