How to run specific automation tests from testsuite using tcm.exe? - coded-ui-tests

I have designed Coded UI tests in Visual Studio 2012. I have associated them with manual tests from Test Manager.
How to run only automation tests with priority = 1 from some test suite?
How to run only testcases which were marked failed by bugs in previous test runs?
I want to run tests using command line something like this:
tcm run /create /title:"Nightly Run" /planid:1 /suiteid:5 /configid:13 /settingsname:"<Name of your automated test settings>" /testenvironment:"<Name of a matching environment>" /collection:<CollectionURL> /teamproject:<Team Project name>
Any ideas?

Do you have the Agent and Controller configures for MTM (Microsoft Test Manager)?
If so, well you can do that from MTM. Create a Query-based test suite with the criteria as you described #1 and #2, this will generate a test suite for you. You can then select the tests in that suite, right-click and run the tests. This is what I'm doing today.
If you want to do this using command line options, then maybe look into how you can call that query-based test suite. I never used cmd line so far.

Related

How to retrieve VsTest Test Plan test case id during Azure pipeline is running and use that in automation code

Use Case:
Define a Test Plan, Test Suite and add test cases to it on ADO.
Link multiple (all) the tests on Test Plan to a single MsTest method.
Azure pipeline is setup to run the automation suite using the “Visual Studio Test” task and “Select tests using” option is set as “Test Plan”
I am searching for a solution on when Azure pipeline starts and VsTest task is running, can we get the Test case ID/Name (from ADO Test Plan) which is currently processed to run and provide that ID/Name to automation test method (as a parameter option to MsTest test). Using that test case ID, I will run few control statements in the code to perform desired tasks.
But, everything should happen runtime and the approach should be dynamic. Also, it should support parallel test execution.
Could you please share your thoughts.
TIA.
Akshay J.
Azure pipeline is setup to run the automation suite using the “Visual Studio Test” task and “Select tests using” option is set as “Test Plan”
According to your description, so Visual Studio Test task is configured like below.
In that case, you will know the id of test plan and id of test suite, so you could use Rest API: Test Suites - Get Test Cases to get all test cases in a suite including id and url, and then request this url will get fields.System.Title, that is the name of test case.
BTW, you could use API: Definitions - Get to get this release definition, in the response you will find the following VsTest task and its settings including id of test plan and id of test suite.

How to combine Azure Test Pland with Pipelines?

Currently I am trying to using Azure Test Plans to manage all test cases, but I just found how to build / generate manual test cases. I also make some research about Pipeline and I just write some "hello world" test scripts and using Pipeline to automatically test the code. My question is: How could I combine TestPlans with Pipeline to make the test in pipeline recordable? Thank you so much!
this is how the pipeline looks like
this is how the test code be checked
My question is: How could I combine TestPlans with Pipeline to make
the test in pipeline recordable?
I'm a bit confused about what the recordable mean in your question. To combine TestPlan with Pipeline, you should configure the Test Plan Settings. For example, set a build pipeline(build and generates the test binaries) and a release pipeline with test-related task in your Test Plan Settings.
The normal logic is:
A test plan containing your automated tests, which you have associated with automated test methods using Visual Studio 2017, or Visual Studio 2015 or earlier.
A Team Build pipeline that generates builds containing the test binaries.
The app to test. You can deploy the app as part of the build and release workflow and also use it for on-demand testing.
For more details please check Run automated tests from test plans.

Can't run tests that interact with the desktop

I have downloaded and installed in a windows server 2016 a vs test agent, which was installed by a tool called Test Agent Configuration Tool. I then followed this guide to configure the agent to run tests that interact with desktop - I want to run CodedUI Tests for web projects from whithin my release pipeline.
This is the output from the Test Agent Configuration Tool
When I run my release pipeline I get this error during the test phase:
Error calling Initialization method for test class
Captura.PDV.Web.Test.CodedUI.CodedUITest1:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException: To
run tests that interact with the desktop, you must set up the test
agent to run as an interactive process. For more information, see "How
to: Set Up Your Test Agent to Run Tests That Interact with the
Desktop" (https://go.microsoft.com/fwlink/?LinkId=255012)
If you are
running the tests as part of your team build, you must also set up the
build agent to run as an interactive process. For more information,
see "How to: Configure and Run Scheduled Tests After Building Your
Application" (https://go.microsoft.com/fwlink/?LinkId=254735)
Here is my test task configuration:
Some notes and questions:
I can run the tests calling vstest.console.exe manually from within the server with success
My release pipeline runs on VSTS
I am not using Microsoft Test Manager - Is it really necessary?
Do I need to set up a test lab enviroment?
Do I need to have a controller for the agent?
I just want to run my tests in first place to see how it goes and then proceed to more advanced tests scenarios using MTM
You're mixed up between the old way of doing things and the new way.
You don't need to use MTM -- MTM is deprecated.
You don't need to set up a lab environment. Lab environments are deprecated.
You don't need special test controllers or agents.
All you should need to do in order to run UI tests is:
Set up a build/release agent that runs interactively.
Run the tests on that agent with the Visual Studio Test task with the "Test Mix Contains UI tests" check box checked.
That's it.
I'd also recommend against using Coded UI and instead use Selenium (or Appium for desktop applications); Microsoft is no longer investing in the Coded UI platform and recommends using Selenium as an alternative.

CodedUI - To run tests that interact with the desktop, you must set up the test agent to run as an interactive process

For creating a Build-Deploy-Test Workflow for my Wpf application, I ma using TFS Build definition and MTM to create Environment.
I am using following Steps:
I am Using LabDefaultTemplate.11.xaml in Build Definition
In the Lab Process Settings, I have given the required details as:
Environment: I have created an environment using MTM on the VM
in the environment I have added a Desktop Client(the same VM only) in the machines List
Please note that my Test Controller, agent, MTM all are on the VM only
Build: I have selected an existing build definition and it's working fine.
Deploy: I have specidfied command for application installation(running of msi file)
also, In the deploy section only, at the end I have specified a batch file where I am calling my CodedUI tests via command line(using VSTEST.CONSOLE.EXE)
Test: Not using it i.e. Not checked the "Run these Tests in Environment"
When I run this build definition, build creation, and installation are working fine but failes to run the codedui tests. Getting following error:
Error Message:
Error calling Initialization method for test class CodedUITestProject1.AISTest: Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException: To run tests that interact with the desktop, you must set up the test agent to run as an interactive process. For more information, see "How to: Set Up Your Test Agent to Run Tests That Interact with the Desktop" (http://go.microsoft.com/fwlink/?LinkId=255012)
If you are running the tests as part of your team build, you must also set up the build agent to run as an interactive process. For more information, see "How to: Configure and Run Scheduled Tests After Building Your Application" (http://go.microsoft.com/fwlink/?LinkId=254735)
Stack Trace:
at Microsoft.VisualStudio.TestTools.UITesting.Playback.Initialize()
at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestExtensionExecution.BeforeTestInitialize(Object sender, BeforeTestInitializeEventArgs e)
at Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestExecution.RaiseBeforeTestInitialize(BeforeTestInitializeEventArgs args)
at Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestExecuter.RunInitializeMethod()
Test Run Failed.
Also, I have made sure that test agent is configured as an interactive process.
Any Help would be highly appreciated.
The issue got resolved after setting the build controller also to run as a interactive process.

Couldn't run my test using Microsoft Test Manager

When I'm running the test in Microsoft Test Manager I get an error: The build directory of the test run either does not exist or access permission is required.
What does it mean? Where can I check build directory?
I suppose you are running automated tests.
If you are running automated test in Microsoft Test Manageg (MTM) you have Test Case(s) automated by your test implementation.
So MTM need to know where is the drop location of the build building your tests.
That means you have to:
Create a Build definition that build the code implementing your tests.
Configure MTM to use the drop location of this build definition.
You can check which build MTM is currently using here:
(I suppose you will have "undefined" standing there.)
You can configure which build is to use here:
Just check here how to configure your Test Plan which build to use when running tests: Creating and Defining a Test Plan
Additionally I would highly recommend you this free e-book: Testing for Continuous Delivery with Visual Studio 2012

Resources