-
Notifications
You must be signed in to change notification settings - Fork 325
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
Unable to filter to just tests with default TestCategory #2818
Comments
@aaronla-ms I didn't fully understand your concern. What do you want to achieve by running that command? If you want to run all tests which do not have
Please use this doc for more info. |
No dice. That still executed some tests I was trying not to run. E.g.: [TestMethod]
public void TestMethod1()
{
}
[TestMethod]
[TestCategory("RequiresSpecialEnvironment")]
public void TestMethod2()
{
Assert.AreEqual("SPECIAL", System.Environment.GetEnvironmentVariable("SPECIAL"));
}
I've got thousands of tests. I'd rather not have to go through and specially annotate them. Not only would that be unnecessary churn, but it would be error prone to expect devs to specially annotate all normal unit tests. Previously, we used a different runner that let us just filter to only run the tests with no special categories set, but we're trying to migrate to retail tools. |
You are right, it checks for usual Not sure how to do it now, but let us check, if we can do this in other way with already implemented functionality. |
Relates to #1724 |
I'd like my tests to run with dotnet sdk 7 and nunit framework and still all tests are running (instead of just running all tests without category). This is my filter expression to select all empty categories: Would be great to see some progress at this issue. |
Using a RunSettings file in a dotnet 8 SDK project, I found the following syntax to work for tests without an assigned TestCategory: A minimal example of a RunSettings file: <?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<TestCaseFilter>(TestCategory = null) | ((TestCategory != Integration) & (TestCategory != UnfinishedFeature))</TestCaseFilter>
</RunConfiguration>
</RunSettings> |
I immediately tested this good news from @faiteanu, so I updated my dotnet test command like this Unfortunately, it doesn't work out for my scenario: it doesn't find my unassigned tests :-( |
+1 on needing this. When I run a PR Build, I would like to specify that all regular unit tests (those without an assigned category) get run. But there is no way to do this, outside of specifying a |
This is a new feature and won't be implemented, we are focusing on adding new features to Testing.Platform instead. https://aka.ms/testingplatform |
Description
First reported by a customer in 2013 before it was part of dotnetsdk, the
--filter
option doesn't permit empty string when setting TestCategory filter. This prevents uses from selecting just those test where TestCategory was not specified. As there's no way to require TestCategory to be set, this effectively prevents users from running just the "default" test of unit tests with a simple self contained TestCategory query.Steps to reproduce
[Expected]
.
[Actual]
Expected behavior
Run the one test, and passes
Actual behavior
Fails, see above log
Diagnostic logs
N/A
Environment
The text was updated successfully, but these errors were encountered: