-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/TestCaseFilter does not support ClassName property #1231
Comments
The properties that are supported by the adapter is: FullyQualifiedName (which is often used with In your case, you could use We'll try to get that MS documentation updated for NUnit too. PS: Also look up the |
Thanks for the response! Good to know the supported properties. I looked further into the VSTest Azure pipeline task behavior and found that at some point the /TestCaseFilter expression used for rerunning test cases changed from using FullyQualifiedName to ClassName and Name: So, I think that's the root of my issue -- I'll need to see whether a change is planned for the pipeline task (since I don't think I can override this behavior, other than specfiying and older version of the task). |
Have you considered switching to use a yaml based pipeline (I assume you're using the classical now, as you refer to the VSTest). Doing that would allow you to use |
Actually, (just checked) the If you give it a test method name, it will run all tests with that name If you give it a test class name, it will run all tests within that class If you give it a namespace, it will run all tests within that namespace |
We're using yaml pipelines for builds, but have many release pipelines too (which are stuck on classic for now). I think I'd like to move to That said, maybe I should just look into dropping the VSTest task and implement my own rerun via |
Expected behavior
The VSTest documentation for the TestCase filter command line option (
/TestCaseFilter
) describes supported properties for a couple test frameworks. For MSTest, "ClassName" is a supported property and the example provided in the documentation suggests this represents the fully qualified name of the test fixture class, i.e. {Namespace}.{ClassName}.I'm interested in the ClassName property because I am using the VSTest task in an Azure pipeline to execute tests and am trying to enable rerunning failed test cases through its "rerunFailedTests" property. When I configure my pipeline this way, I see that the task identifies failed test cases and then tries to rerun them using a /TestCaseFilter expression containing ClassName and Name.
(Maybe the VSTest Azure pipeline task should not do be doing this and I should raise a bug there -- I figured I would start here though to understand what properties the NUnit test adapter supports. While reviewing open issues here, I did see #1202, which might ultimately be the same problem, but I wanted to remove Azure pipelines from the scope to make the investigation simpler -- please let me know if I should close this issue and provide information there instead.)
Actual behavior
When running tests with the NUnit framework through VSTest, /TestCaseFilter expressions containing ClassName fail to discover any tests.
For what it's worth, I looked at src/NUnitTestAdapter/VsTestFilter.cs and didn't see ClassName included among the test case properties.
I have tested this with the current latest stable versions of the relevant packages:
I have Visual Studio 2022 17.12.0 installed.
Steps to reproduce
Below is a rudimentary .NET 8.0 project that I used to test this behavior.
TestProject1.sln
TestProject1.csproj
UnitTest1.cs
After compiling, I ran the following VSTest command (using the VS2022 Developer Command Prompt) with the expectation that the TestCase filter would run all tests belonging to the specified class (i.e. tests Test1 and Test2):
vstest.console.exe TestProject1.dll /TestCaseFilter:"ClassName=TestProject1.Tests"
However, NUnit3TestExecutor does not discover any matching test cases:
The text was updated successfully, but these errors were encountered: