-
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
Filtering default traits/categories in the .runsettings file #2273
Comments
cc @AbhitejJohn |
tagging @vritant24 here as well as this would also require changes in VS TE window. |
Tracking dotnet/runtime issue: dotnet/runtime#1161 |
To provide an example of why this is necessary, in https://github.com/dotnet/runtime we attributed tests which are failing either on all or some platforms with attributes that allow excluding them by filtering on that trait: https://github.com/dotnet/runtime/blob/04f22268efb4434b7cd81e8ae2c3354be99fd4a7/src/libraries/System.Composition/tests/CircularityTests.cs#L119-L127 In this example, This feature most certainly makes sense to be implemented in .runsettings. Possibly with one of the following syntaxes:
<TraitFilters>
<TraitFilter name="include" value="abc" />
<TraitFilter name="exclude" value="failing" />
</TraitFilters>
<TraitFilters>
<TraitIncludeFilter value="abc" />
<TraitExcludeFilter value="failing" />
</TraitFilters> |
I've created Bug 1069896 in azdo to track the changes needed on the VS TE Window. |
I was briefly looking into this yesterday, and I am thinking if it we should take advantage of the filter syntax that already exists in the test platform because that allows for multiple ways of matching (equal, not equal and contains) and pointing the filter to different properties of the test (name / category etc.). https://github.com/microsoft/vstest-docs/blob/master/docs/filter.md |
So basically adding the ability to specify the |
Yes that is what I meant. And yes it would leak the details to runsettings file, but the --filter / --TestCaseFilter is already leaking those details. What it gives us is that we don't need to come up with an alternative DSL to unify the possibilities already present in On the other hand the user will have to provide the filters for all the test adapters that they are using, but it's the same situation for the filter parameter as well, for example, including tests in both these files is done like this # file UnitTestProject29\UnitTest1.cs
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace UnitTestProject29
{
[TestClass]
public class UnitTest1
{
[TestMethod]
[TestCategory("include")]
public void TestMethod1()
{
}
}
}
# file XUnitTestProject1\UnitTest1.cs
using System;
using Xunit;
namespace XUnitTestProject1
{
public class UnitTest1
{
[Fact]
[Trait("Category", "include")]
public void Test1()
{
}
}
} |
Sounds good, let me know if I can help somehow. Thanks. |
@vritant24 there is a PR, I marked you as a reviewer: # file runsettings.settings
<RunSettings>
<RunConfiguration>
<TestCaseFilter>TestCategory=include</TestCaseFilter>
</RunConfiguration>
</RunSettings>
Here is my project that I used to figure this out, it uses the nugets from the locally built vstest and testfx, let me know if you need any help plugging this into VS:
|
@ViktorHofer what test framework are your tests using, on xUnit it does not run the filtering during discovery, and would require change in their adapter.
|
Yes we use xunit. cc @onovotny |
The filtering happens in the run phase currently: I honestly don't remember why we don't/didn't do it in discover. @bradwilson? |
If you filter during discovery, make sure it happens during discovery for the purposes of execution (which is how tests run in VSTest at least 99.9% of the time). |
Looking at the blame, it looks like it's probably just a case of the filter being added in one place where it should've been added in two. And not surprisingly, it was added to the place where it made the 99.9% case work properly. 😉 |
Thanks @bradwilson. That being the case, I should be able to put the logic in the discover phase as well and get a 2.4.2 build of the vs test adapter out. Then all kinds of templates would need to be updated. |
@onovotny Great, I'll take care of updating our templates in https://github.com/dotnet/test-templates once this is done and tested. |
@onovotny please let us know if we can help you in any way to speed up the process. |
A PR would help speed things along - my plate is pretty full and I'm not sure when I'll be able to get to it. |
@clairernovotny I will consider PR to xUnit it once we get this work completely. MSTest works so we can use that as the pilot for the whole functionality, because the changes to the platform need to ship with VS, but xunit / nunit / mstest can be updated via nuget. |
Jakub, just to understand this better, don't the changes necessary here also ship via nuget? |
@ViktorHofer this will impact both source based test analysis which ships directly with VS and the vstest.console that is also shipping with VS. So the changes will have to be inserted into VS once we are done. You can still get vstest console separately, but if you are will be using this from VS Test Explorer you need to wait till it ships with VS. If this was just impacting test host, or some of the test adapters (like xunit adapter) you could get it by updating your nuget package. #2287 (comment) this and the subsequent comments will hopefully give you some more details about how this ships. |
Thanks a lot for clarifying. |
This still needs the xUnit part. Re-opening. |
xUnit PR created, will continue discussion there. This is done for vstest, closing. |
VS Test Explorer displays all discovered tests by default. In dotnet/runtime some tests are disabled via traits (i.e. ActiveIssue, SkipOnTargetFramework, ConditionalFact, ConditionalTheory). These tests should be filtered out by default inside the VS Test Explorer by introducing a trait filter entry in the .runsettings file. Same applies to when running
dotnet test
on the CLI, default traits should be recognized in the.runsettings
file..runsettings
file needs a trait filter option, i.e.<TraitFilter>-failing,-IgnoreForCI</TraitFilter>
cc @ManishJayaswal @singhsarab this is part of the the design document that I created a few months ago: https://github.com/ViktorHofer/designs-private/pull/1.
The text was updated successfully, but these errors were encountered: