Ranorex Studio is renowned for its robust no-code capabilities, which allow tests to be automated seamlessly across web, mobile, and desktop applications. Beyond its intuitive recording features, Ranorex Studio allows custom code module creation using C# or VB.NET,...
Microsoft Team Foundation Server supports your complete application life cycle management (ALM) process, from source control to automated builds and quality assurance. This blog post illustrates how to implement Coded UI tests that execute Ranorex Studio automation code or even entire Ranorex Studio test suites using Microsoft Test Manager.
Infrastructure
First, you need a working infrastructure to run your Coded UI test with integrated Ranorex Studio automation. Please review Microsoft documentation regarding Team Foundation Server (TFS) Microsoft Test Manager, and Coded UI Tests or this getting started blog post.
In the mentioned infrastructure the Coded UI Test will be implemented on the Visual Studio workstation. This Coded UI Test will kick off the Ranorex automation.
You will use this TFS infrastructure on a Visual Studio workstation to implement a Coded UI test, which will execute the Ranorex Studio test automation. This Coded UI test can then be added to a TFS test case as the associated automation process, as described in this article.
Implementing Coded UI Tests to Execute Ranorex Automation
After providing a working infrastructure, you can create your Coded UI Tests with Ranorex Studio test automation.
You must have the Ranorex Studio main components – and at least a valid runtime license – installed on each machine on which you are going to execute Ranorex Studio code.
After creating a new Coded UI test project and adding a new Coded UI test to it, you could record your Coded UI test. Because we are going to execute Ranorex code instead, you can cancel this step.
The new Coded UI test should contain a test method similar to the one shown below:
[TestMethod] public void CodedUITestMethod1() { }
Starting from this point, you can either implement your own Ranorex code within your test methods or execute an entire Ranorex Studio test suite from your test methods.
No matter which approach you are going to follow, it’s necessary to add references to the Ranorex libraries and add a “using”-directive for the Ranorex namespace as described in the “Visual Studio Integration”-section of our user guide.
After adding the references and the using directive, you can simply start writing your Ranorex automation code as usual.
The recommended way of adding Ranorex Studio test automation to a Coded UI test is to execute either a complete Ranorex test suite or specific Ranorex Studio test cases from your test method.
When running the test suite using the TestSuiteRunner class, you must specify a container type that is in the project containing the test suite. To use the Program class as the container type, you must make that class public. Your Program.cs file should look like the following example:
... namespace MyTest { public class Program { ... ... } } ...
Change the Output type of the generated project to Class Library and build your Ranorex Studio test suite (<F8>).
After doing so, add a reference to the Ranorex Studio test suite project to the Coded UI test project.
Additionally, add the Ranorex Studio test suite file to (rxtst) to your Coded UI test project and set the Copy to Output Directory behavior to Copy always.
To execute the Ranorex Studio test suite, copy the test suite file to the test machine where the test will be executed.
This is done using the DeploymentItem attribute, which identifies the test suite file and the relative directory where the file should be deployed.
[TestMethod] [DeploymentItem("MyTest.rxtst")] public void CodedUITestMethod1() ...
Refer to the Ranorex Studio User Guide chapter Visual Studio integration › Write some Ranorex automation code, for instructions on how to initialize the assembly.
... public void CodedUITestMethod1() { Ranorex.Core.Resolver.AssemblyLoader.Initialize(); Ranorex.TestingBootstrapper.SetupCore(); ...
... public void CodedUITestMethod1() { Ranorex.Core.Resolver.AssemblyLoader.Initialize(); Ranorex.TestingBootstrapper.SetupCore(); Ranorex.Keyboard.AbortKey = System.Windows.Forms.Keys.Pause; int error = Ranorex.Core.Testing.TestSuiteRunner.Run(typeof(MyTest.Program), "/zr /zrf:report.rxzlog"); TestContext.AddResultFile("report.rxzlog"); if (error != 0) throw new Ranorex.RanorexException("Test run failed! See report.rxzlog for further details!");} ...
The next line will start the test suite with the given command line arguments.
The argument “/zr” will trigger the test suite to generate a zipped report, which makes it easier to attach the report to the test case executing the test method.
Use the argument “/zrf” to specify the name of the zipped report.
Command line arguments allow you to execute a single test case (“/tc” argument) or launch a defined run configuration (“/rc” argument).
You can find a list of all available command line arguments in the section “Running Tests without Ranorex Studio” in our user guide.
The next line of code attaches the zipped report file to the test results, which allows you to analyze the test run directly from MTM.
The if statement throws an exception if the test suite execution fails, which will make the test case fail, too.
After checking in the test and building the solution, execute the system under test by triggering the corresponding test case via MTM, as described in this article.
Conclusion
Following the steps in this blog post, you can integrate your Ranorex Studio automated tests in an existing Team Foundation Server infrastructure.
With this integration, you will be able to execute Ranorex Studio UI automation using Microsoft Test Manager.
Related Posts:
Support Corner: API Testing and Simple POST Requests
Ranorex Studio is renowned for its robust no-code capabilities, which allow tests to be automated seamlessly across web, mobile, and desktop applications. Beyond its intuitive recording features, Ranorex Studio allows custom code module creation using C# or VB.NET,...
The Top 10 Test Automation Challenges
It’s difficult for any IT organization to execute DevOps effectively without test automation. However, it’s often easier said than done. Overcoming the challenges of automated software testing can end up slowing down product delivery and impacting quality, the exact...
7 Best Android Testing Tools
There are more and more Android testing tools available for mobile app developers. These are our favorites for performance, accessibility, and security.