Search code examples
azure-pipelinesnunitvstest

VSTest@2 task doesn't discover NUnit parametrized test cases when using testSelector = testPlan


I am using VSTest@2 task(using testSelector = testPlan) and NUnit to run my automation tests in Azure DevOps but for some strange reason my parametrized test cases are not being discovered.

For example I have the following test case:

[TestCase("Text")]
[TestCase("Number")]
public void Example_Test(string dataType)

Respectively I have created only 1 test case in Azure DevOps which has an associated automation with the test method name and the following steps and parameters:

enter image description here

Basically my test suite contains 4 test cases of which 1 is a parametrized test case but when running my tests using VSTest@2 task I am getting the following message:

[RunStatistics]This execution slice with id '2555', received '4' testcases to execute out of which '3' is discovered.

I am not really sure what the issue is here, would appreciate any feedback or suggestions.


Solution

  • There's a 1:1 mapping between "Test Methods" (your automated tests) and Test Cases.

    When you use the Associate to Test Case feature it sets the Automated Test Name in the "Associated Automation" tab:

    Associated Automation

    This field can only contain a single value. As per the documentation:

    You can't associate more than one test method with a test case, but you can associate a test method with more than one test case.

    The fact that your Test Case is defined as parameterized has no effect:

    The parameters in a test case aren't used by any automated test that you associate with a test case. Iterations of a test case that use these parameters are for manual tests only.