Freigeben über


Testing - Test Case automation: Executing automated Test Cases in a remote environment.

The objective of this article is to help you with the steps to Automate a Test Case Work Item.

To automate a Test Case, first, we associate the Test Case with a Coded Test method.
You can associate a unit test, coded UI test, or generic test to a test case. You’ll want to link a test method that performs the test described by the test case. Typically, these are integration tests.

In this article, I’m going to use Coded UI test method, which follows steps below,

  1. Create a Coded UI test
  2. Associate the Coded UI Test Method with Test Case work item
  3. Build the Coded UI project in a build definition
  4. Add test plan to build
  5. Execute the test case in environment

Check this article to install and set up Controller/Agents

  1. Create Coded UI test

Open Visual Studio

Click on File->New->Project

Select Coded UI Test Project

1

Coded UI test can be created in two ways as shown in below image, I choose to go with First option (Record actions, edit UI map or add assertion), details about second option can be found from below article

Generating a Coded UI Test from an Existing Action Recording: https://msdn.microsoft.com/en-us/library/dd286652(v=vs.140).aspx 2

Record a scenario, generated the method and added the solution to source control

3

After building the solution, test method will be shown in Test explorer.

Right click on the test case and run to validate if it is executing successfully

4

  1. Associate the Coded UI test method with Test case work item

Keep the Coded UI project solution opened in Visual Studio.

Open test case in Visual Studio.

Associated test method with your test case.

567

  1. Build the Coded UI project in a build definition.

Create a build definition to build Coded UI test project:

Create a build definition that contains just the location where your assemblies are shared. The same assemblies can be used to execute the test method on agent machine.

Create or edit a build definition: https://msdn.microsoft.com/en-us/library/ms181716(v=vs.120).aspx

 

  1. Add test plan to build

Open MTM and connect to Test plan

8

Navigate to Track page in MTM

Select the build that you created for Coded UI project

9

Click on Assign to Plan button to associate the build with test plan

10

  1. Execute the test case in environment

Switch to Test page in MTM

Select the test case

Right click on it and choose Run with options

11

 

Select the environment that want to execute test case and verify remaining options as well and click on Run

Note: Make sure that your test agent machine is in active state or switch to your test agent machine to see if the test case execution is happening 12

You can see the execution of test case happening on environment

1314
In my case I see that my test case executed successfully on test agent machine :)

Content: Venkatappala Raju Chakravaram
Review: Sinjith Haridasan Reeja