question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Filtering tests with any "PropertyAttribute"

See original GitHub issue

Hi,

vstest.console.exe has /TestCaseFilter switch (and in IVsTestConsoleWrapper API there’s TestCaseFilter in RunSettings, in dotnet test it’s --filter AFAIK).

But it seems it’s not possible to run only tests which has specific PropertyAttribute. For example given following:

        [Property("Bug", "12345")]
        [Test]
        public void Test2()
        {
            Assert.Pass();
        }

I would like to be able run something like this: vstest.console.exe NUnitTestProject1.dll /TestCaseFilter:Bug=12345. But it does not seems to work - no test is executed. Am I doing it wrong, or is there no support for this?

According to https://github.com/microsoft/testfx/issues/731 it must be supported by test adapter (it is supported by xUnit, not supported by MSTest).

If it is not supported by NUnit, I’d like to ask to add such support.

Please see the above issue for some more details and simple solution with 3 UT projects (mstest, xunit, nunit): ClassLibrary1.zip I have tested this with vstest.console.exe from microsoft.testplatform.16.7.0 nuget package, with NUnit3TestAdapter 3.15.1.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
shack05commented, Jun 1, 2021

Hello @OsirisTerje, That package fixes it for me. Thanks, that’s a very useful feature.

1reaction
OsirisTerjecommented, Sep 1, 2020

@pkruk2 I need to check this out (aka debug) to see what happens here. I can confirm it doesn’t work, and I see there is an exception (using the 4.0.0-alpha.1 adapter) that says it doesn’t find the “Bug” in the selection criteria. We should be able to fix this, given the vstest guys says they’re sending the correct stuff down to us. Also, from earlier posts I see this have been working earlier, but I am not sure when this stopped working, so - we do have a regression bug here.

I also see it works in Visual Studio: image

So there is something in the way that vstest and dotnet test sends the arguments.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I filter NUnit tests based on Property in Visual Studio ...
Is it possible to construct a Visual Studio Test Explorer search expression that will actually filter NUnit tests based on the name AND...
Read more >
Property
Property. PropertyAttribute provides a generalized approach to setting named properties on any test case or fixture, using a name/value pair.
Read more >
SysTest filtering using class and method attributes
This article outlines attributes that can be used with SysTest classes and methods for the purpose of test filtering.
Read more >
NUnit - Property
The Property attribute provides a generalized approach to setting named properties on any test case or fixture, using a name/value pair.
Read more >
Class PropertyAttribute | Package Manager UI website
Class PropertyAttribute. Use this attribute to have a property generated for the member. Inheritance. System.Object.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found