Skip to content

Conversation

@layomia
Copy link
Contributor

@layomia layomia commented Mar 19, 2020

Following #33391, the static test methods were not being run.

dotnet msbuild /t:test /p:xunitmethodname=*PolymorphicTests*

Before this PR

System.Text.Json.Tests  Total: 50, Errors: 0, Failed: 0, Skipped: 0, Time: 0.297s

After

System.Text.Json.Tests  Total: 85, Errors: 0, Failed: 0, Skipped: 0, Time: 0.327s

@layomia layomia added area-System.Text.Json test-enhancement Improvements of test source code labels Mar 19, 2020
@layomia layomia added this to the 5.0 milestone Mar 19, 2020
@layomia layomia requested a review from steveharter March 19, 2020 17:29
@layomia layomia self-assigned this Mar 19, 2020
@stephentoub
Copy link
Member

Wait, I'm not understanding. Are you saying xunit is no longer running static test methods in general? Or is there something specific to these cases? Thanks.

@layomia
Copy link
Contributor Author

layomia commented Mar 20, 2020

@stephentoub, #33391 introduced a pattern where the class containing the test methods is abstract, and test variants derive from this class. This approach allows us to test multiple overloads of the serializer with the same logic.

The side effect of this seems to be that static test methods, and methods with the [Theory] attribute are not run. Static test methods are ignored, and xunit throws a NotSupportedException for theories.

In general, tests that don't use this pattern should run as expected.

@stephentoub
Copy link
Member

introduced a pattern where the class containing the test methods is abstract, and test variants derive from this class

Ah, ok. Phew :)

@stephentoub stephentoub merged commit a449356 into dotnet:master Mar 20, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
@layomia layomia deleted the polymorphic_tests branch May 18, 2021 07:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Text.Json test-enhancement Improvements of test source code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants