Create All in one Test case

Best practices, code snippets for common functionality, examples, and guidelines.
bberrabah
Posts: 26
Joined: Wed Dec 20, 2017 6:18 pm

Create All in one Test case

Post by bberrabah » Wed Mar 14, 2018 11:05 am

Hello;
i'm working on test automation for insurrance product with some 10 medium complexity steps.
I have to create 10 test cases for each use case.
My scenario is:

Extranet Login
Member / CoMember information
Insurrance History
Medical History
Financial Investment repartition
....

I choosed to create a smart folder for each step, and if needed smart folder for do if-then-else to decide which atomic action do according to the context. For example, in the second step, i have to introduce the insurance member information ( mandatory sub-step), and if he/she have a co-member, a condition on the appropriate smart folder will make me able to decide if i execute it or not.

For Data, i choosed to use Excel Data will specifica data tab for each step (top smart folder), and i checked All rows in the Data source Tab on propertis Dialog.

The problem is that when i use smart forlders like that ranorex will execute 10 times the actual smart folder, instead of executing each step one time and getting to the next one.

I want your help for an idea to do this well!

Regards

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Create All in one Test case

Post by odklizec » Thu Mar 15, 2018 9:30 am

Hi,

It's hard to suggest something reliable, without seeing your test suite. But my guess is, that you just need to create a data connector per each smart folder (representing each step). Then it may be possible to use the same excel file (used with each smart folder). You just have to limit the range for one row per smart folder? But again, without seeing your test suite structure, it's hard to tell if it's the best approach? ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

bberrabah
Posts: 26
Joined: Wed Dec 20, 2017 6:18 pm

Re: Create All in one Test case

Post by bberrabah » Thu Mar 15, 2018 9:39 am

Hi;

It's possible to do this using this code (to be inserted somewhere at the begining of the test)

Code: Select all

int dataRange = Ranorex.Core.Reporting.TestReport.CurrentTestIterationActivity.Index-1;
TestSuite.Current.GetTestContainer("SmartFolder1").DataContext.SetRange(dataRange, dataRange);
TestSuite.Current.GetTestContainer("SmartFolder2").DataContext.SetRange(dataRange, dataRange);
...
Best regards

bberrabah
Posts: 26
Joined: Wed Dec 20, 2017 6:18 pm

Re: Create All in one Test case

Post by bberrabah » Mon Mar 19, 2018 1:11 pm

I find better, i created a recursive function that set the adequate datarange for each SmartFolder

Code: Select all

private void setDataRangeForContainerAndChilds(ITestContainer testContainer, int dataRange){
	
	testContainer.DataContext.SetRange(dataRange, dataRange);

	Report.Log(ReportLevel.Info, "Client", String.Format("Test Container << {0} >> DR << {1} -- {2}>> ", testContainer.Name, testContainer.DataRange.MinRange, testContainer.DataRange.MaxRange));

	SmartFolderNode smartFolderNode= testContainer as SmartFolderNode;
	IEnumerable<TestCaseNode> children = smartFolderNode.GetDescendantTestCases();
	
	foreach (TestCaseNode testcase in children){
		this.setDataRangeForContainerAndChilds(testcase, dataRange);
		
	}
}