Azure DevOps automatic Test Case Association
janono.ado.testcase.associate
Janono.ADO.TestCase.Associate is an extension for automatic association of test methods from code to Test Cases in Azure DevOps Test Plans.
janono.ado.testcase.associate.cli
Extension was created as current approach for association is manual activity.For each test case with can be very time consuming, susceptible to mistakes (as each manual activity), time costly in maintenance. Current approach also requires Visual Studio with is not needed in case of using extension.
Extension consists of 2 components
- Nuget package janono.ado.testcase.associate that contains decoration attribute, to mark test and organization
- CLI that is executing actions like association janono.ado.testcase.associate.cli
Getting started
-
Create Test Project or open existing, supported any with MSTest, NUnit, xUnit written in .NET Core or .NET Framework version.
-
Add latest nuget package “janono.ado.testcase.associate” from https://www.nuget.org/packages/janono.ado.testcase.associate/ .
- On Test Class level add organization attribute
[janono.ado.testcase.associate.Organization("janono-pub")]
where replace value “janono-pub” your azure devops organization name.
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ExampleTestProject
{
[TestClass]
[janono.ado.testcase.associate.Organization("janono-pub")] //<---
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
//yours test method content
//...
//
}
}
}
- On Test Method level add test case attribute
[janono.ado.testcase.associate.TestCase(5)]
where replace ‘5’ with yours ‘test case id’ for with you want to associate automation.
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ExampleTestProject
{
[TestClass]
[janono.ado.testcase.associate.Organization("janono-pub")]
public class UnitTest1
{
[TestMethod]
[janono.ado.testcase.associate.TestCase(5)] //<---
public void TestMethod1()
{
//yours test method content
//...
//
}
}
}
- Optionally add using statement namespace “using janono.ado.testcase.associate” to use short name for attributes
[janono.ado.testcase.associate.Organization("janono-pub")] -> [Organization("janono-pub")]
[janono.ado.testcase.associate.Organization("janono-pub")] -> [TestCase(5)]
using Microsoft.VisualStudio.TestTools.UnitTesting;
using janono.ado.testcase.associate; //<---
namespace ExampleTestProject
{
[TestClass]
[Organization("janono-pub")] //<---
public class UnitTest1
{
[TestMethod]
[TestCase(5)] //<---
public void TestMethod1()
{
//yours test method content
//...
//
}
}
}
-
Build projects or solution for generating ddl assembly for tests
-
Download latest CLI release janono.ado.testcase.associate.cli for your platform Windwos, MacOs, Linux as cli is written in cross platform .NET Core. Extract to folder where you would like to keep it.
-
Open console with you are using, go to folder where you extract cli. Type “janono.ado.testcase.associate.cli.exe” press enter, now you will see the possible options.
Options:
-am, --authMethod <Basic|oAuth|PAT> (REQUIRED) Authentication method Oauth Token, PAT,Basic
--authValue <authValue> (REQUIRED) The password, Personal Access Token or OAuth Token to authenticate
--action <Associate|List> (REQUIRED) Action
--path <path> (REQUIRED) Path to dlls with tests, supporting '*' wildcards.
--version Show version information
-?, -h, --help Show help and usage information
-
Pass parameters for CLI
- –authMethod PAT or oAuth(in coming future)
- –authMethod “PAT” PAT (personal access token)
- –path to dll file with test for association
- –action “List” for scan dll test assembly and check if need to update association, or “Associate” for association test methods to test cases also cover update case
-
Example –action “List”
janono.ado.testcase.associate.cli.exe --authMethod PAT --authValue [yours PAT] --path D:\ExampleTestProject\bin\Release\net6.0\ExampleTestProject.dll --action List
-
Example –action “Associate”
janono.ado.testcase.associate.cli.exe --authMethod PAT --authValue [yours PAT] --path D:\ExampleTestProject\bin\Release\net6.0\ExampleTestProject.dll --action Associate
-
Result, now on test case workitem on “Associated Automation” tab you will see automatically associated automation with will be executed run automated tests from test plans.
Features planned
- Add support for Azure devops server.
- Add Azure DevOps Marketplace extension with dedicated build task for making automatic association.
- Generate CLI for multiple platforms.
Comments