In my Azure Pipeline, I'm trying to build and run the code. So I have included "NuGet Restore", "Build Solution" and "VS Test" task.
When I'm trying to apply filter criteria in VS Test, it shows error that no Test case found with in that search criteria:
NUnit couldn't find any tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.Objects\bin\Release\NUnit3.TestAdapter.dll
Running all tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.PageObjects\bin\Release\NUnit3.TestAdapter.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.PageObjects\bin\Release\NUnit3.TestAdapter.dll
Running all tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.Resource\bin\Release\NUnit3.TestAdapter.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.Resource\bin\Release\NUnit3.TestAdapter.dll
Running all tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\Automation.TestSuite.dll
NUnit3TestExecutor converted 213 of 213 NUnit test cases
Skipping assembly - no matching test cases found
Running all tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.Test.WebApi.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.Test.WebApi.dll
Running all tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.TestManagement.WebApi.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.TestManagement.WebApi.dll
Running all tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\NUnit3.TestAdapter.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\NUnit3.TestAdapter.dll
NUnit Adapter 3.9.0.0: Test execution complete
No test matches the given testcase filter `Category = Enrollment` in C:\AzureAgent2\_work\2\s\Main\Business\Automation.Objects\bin\Release\NUnit3.TestAdapter.dll C:\AzureAgent2\_work\2\s\Main\Business\Automation.PageObjects\bin\Release\NUnit3.TestAdapter.dll C:\AzureAgent2\_work\2\s\Main\Business\Automation.Resource\bin\Release\NUnit3.TestAdapter.dll C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\Automation.TestSuite.dll C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.Test.WebApi.dll C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.TestManagement.WebApi.dll C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\NUnit3.TestAdapter.dll
My Test Suite will Look like.
// [Category("Enrollment")]
// [Category("Regression_TS")]
// [Test, TestTimeOutValue, Parallelizable(ParallelScope.Self), TestDescription("Enroll_001 - Enroll Button\n" +
// "Enroll_002 - Log In to Business\n" +
// "Enroll_003 - Log Out of Business")]
I tested this and it works fine.
Test project
using NUnit.Framework;
namespace UnitTestProject1
{
public class UnitTest1
{
[Category("Enrollment")]
[Test]
public void TestMethod1()
{
Assert.True(true);
}
[Test]
public void TestMethod2()
{
Assert.True(true);
}
}
}
Packages installed
<packages>
<package id="NUnit" version="3.12.0" targetFramework="net48" />
<package id="NUnit3TestAdapter" version="3.16.1" targetFramework="net48" developmentDependency="true" />
</packages>
In the VSTest task you add following code in the filter
TestCategory=Enrollment
If you use YAML build, it should be this line
testFiltercriteria: 'TestCategory=Enrollment'
And it looks like this