Skip to content
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

Custom Trait-Attribute causes non-stop Discovery of Test-Methods in VS 2019 #176

Open
lanluu opened this issue Oct 7, 2019 · 7 comments

Comments

@lanluu
Copy link

lanluu commented Oct 7, 2019

Hi,

in VS 2019 I am suffering a situation in that the discovery of xUnit Test-Methods in Test-Explorer (i.e. testhost process) runs endless, if any Test-Method has Custom-Trait-Attribute i.e. by adding any class inhered from ITraitAttribute and ITraitDiscoverer, for instance: https://github.com/xunit/samples.xunit/tree/master/TraitExtensibility

I would appreciate any idea in this case.

Thanks and best regards!

@lanluu
Copy link
Author

lanluu commented Oct 7, 2019

As I figured out, this situation can caused in case the Custom-Trait-Attribute throws any Exception in Constructor e.g. because of validation of input params. For instance:

    [TraitDiscoverer("...", "...")]
    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
    public class ClassificationAttribute : Attribute, ITraitAttribute
    {
        public ClassificationAttribute(params Type[] traits)
        {
            // if you throw any Exception here because of invalid parameters,
            // and any Test-Method has this Attribute with invalid parameters,
            // then testhost process (in Test-Explorer) will run endless.
        }
    }

I hope it might help someones.

@bradwilson
Copy link
Member

Does this only fail in Visual Studio? If so, this issue needs to be moved to the right repo.

@lanluu
Copy link
Author

lanluu commented Oct 8, 2019

Yes, only in Visual Studio. To which Repo should I move this thread?

@bradwilson
Copy link
Member

I'll move it. :)

@bradwilson bradwilson transferred this issue from xunit/xunit Oct 8, 2019
@djalan
Copy link

djalan commented Apr 10, 2024

Same problem in Visual Studio 2022 when you use package SkippableFact for Xunit.
It causes non-stop discovery like 33% of the time.

@djalan
Copy link

djalan commented Apr 10, 2024

Same problem in Visual Studio 2022 when you use package SkippableFact for Xunit. It causes non-stop discovery like 33% of the time.

I tested in a separate project and it seems fine.

BUT.

It is surely because my problematic project has its own class implementing XunitTestFramework. But the problem does not happen all the time.

@bradwilson
Copy link
Member

@djalan If you can provide a repro project that would be very helpful. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants