Remote execution for recorder modules and logging

Class library usage, coding and language questions.
schulle0815
Posts: 6
Joined: Fri Nov 25, 2011 11:19 am

Remote execution for recorder modules and logging

Post by schulle0815 » Fri Nov 25, 2011 12:25 pm

Hi Ranorex-Support,

at the moment we are working on a solution that integrates Ranorex into our own testing solution, so Ranorex can handle the GUI based testing issues that our software does not support in that detail. Our own testing solution is technically based on the Windows Workflow Foundation, so the plan is to trigger single Ranorex recording modules or other Ranorex API functionality (e.g. validation of a specific control value) on the System Under Test (SUT) within Workflow activities. The recordings are created using the Ranorex Recorder and will be executed remotely by our own testing solution (and not by Ranorex Studio) within our test workflows. It should also be possible to use the Ranorex data binding process, so we can send parameters to a specific recording that are than bound to existing TestVariables within the recording module. So far, so good.

For executing Ranorex recordings (ITestModule instances) a single recording and additional parameters are transferred to the SUT (physically separated from the test execution system). The SUT also hosts the Ranorex API. Here I'm then using Reflection to create an instance of the compiled recording and inspect the members of it (e.g. to set values of certain TestVariables directly without using a separate data source) . This instance is than handed over to the TestModuleRunner of the Ranorex API I use for executing the requested test recording on the SUT. The problem is: what is the best way to do that with the ModuleRunner for that special setup? I already tried the following approaches (module is the ITestModule instance):

Code: Select all

 Ranorex.Core.Testing.TestModuleRunner.RunStandalone(module, module.ToString(), true);
When I'm using one of the static RunStandalone() overloads above I'm loosing all values set to TestVariable properties via Reflection before calling that method, because this method internally creates a new instance of the given ITestModule parameter (or so it seems). The good thing is that the method creates a complete log file with a result and returns it, too.

Code: Select all

Ranorex.Core.Testing.TestModuleRunner.Run(module);
The Run() overloads will not delete the TestVariable properties, but after the recording is executed there is no way of telling whether the recording was succesfull or not because the log file is incomplete and contains no result (only a handfull of log messages) and the method does not provide a return value.

Do you have a hint or suggestion that helps me finding a solution for our approach (or maybe I should try a different one)? It would be great to be able to execute the recordings and set the values of TestVariables and have a complete logfile indicating the result.

Thanks and best regards,
Andreas Schulze.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Remote execution for recorder modules and logging

Post by Support Team » Fri Nov 25, 2011 3:27 pm

Hi,
The problem is: what is the best way to do that with the ModuleRunner for that special setup?
I think the best way is to use the "TestModuleRunner.Run(yourModule)" method, but in this case you have to consider that you have to "create/setup" your own Reporter.
I have attached a small sample project where you can see how to setup such a "TestReport".
This should allow you to use the set properties and the reporting functionality.

Regards,
Markus
Ranorex Support Team
Attachments
SmallTestProject.zip
A small sample project
(23.97 KiB) Downloaded 212 times
.
Image

schulle0815
Posts: 6
Joined: Fri Nov 25, 2011 11:19 am

Re: Remote execution for recorder modules and logging

Post by schulle0815 » Fri Nov 25, 2011 4:19 pm

Hi Markus,

thanks a lot for providing the example. Now it seems that I misunderstood/misinterpreted the way the Ranorex runtime creates the overall recording result. I was also a bit confused that the method "TestModuleRunner.Run(yourModule)" does not provide a return value indicating the result of the test recording run. In your example code you set the result of the recording manually:

Code: Select all

TestReport.EndTestCase(TestResult.Passed);
To improve my understanding - in our approach, if we execute a specific recording by using the TestModuleRunner and if that recording runs through without causing any kind of exception, too, I can assume that the recording was executed successfully (in Ranorex terms: TestResult.Passed). Is that right?

Best regards,
Andreas Schulze.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Remote execution for recorder modules and logging

Post by Support Team » Mon Nov 28, 2011 11:03 am

Hi,

to make the whole test case fail if a test module fails you can use following code:
TestReport.EndTestCase(TestResult.PassIfChildrenPassed);
instead of using
TestReport.EndTestCase(TestResult.Passed);
Additionally I would recommend to use a try/catch block when executing the recording with
TestModuleRunner.Run(rec);
as the method TestModuleRunner.Run can throw an exception.

Your code to execute the recording should look something like this:
try 
{ 
    TestModuleRunner.Run(rec);
}
catch (Exception e)
{
    Report.Error(e.ToString());
}
Regards
Tobias
Ranorex Support Team
.
Image