This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Repository navigation
Improve analyzer test infra to split linker tests into separate test cases in the TestExplorer - #2337
Merged
tlakollo merged 6 commits intoOct 28, 2021
Conversation
…cases in the TestExplorer xUnit will not split the test cases if the parameters to the Theory are complex objects. But if the parameter is a single string it will do it. So using a trick to store a string->object mapping and identify the tests by the string. When the test is executed the object representation is looked up from the string and executed.
sbomer
approved these changes
Oct 27, 2021
Had to add ProducedBy to LogContains attribute to handle the static ctor case.
tlakollo
reviewed
Oct 27, 2021
tlakollo
reviewed
Oct 27, 2021
tlakollo
reviewed
Oct 27, 2021
And fix build after the merge
Member
Author
agocke
pushed a commit
to dotnet/runtime
that referenced
this pull request
Nov 16, 2022
…cases in the TestExplorer (dotnet/linker#2337) * Improve analyzer test infra to split linker tests into separate test cases in the TestExplorer xUnit will not split the test cases if the parameters to the Theory are complex objects. But if the parameter is a single string it will do it. So using a trick to store a string->object mapping and identify the tests by the string. When the test is executed the object representation is looked up from the string and executed. * Add ProducedBy to LogContains attribute to handle the static ctor warning discrepancies between linker and analyzer * Remove analyzer specific information in RunTest since now we run all analyzers at the same time Commit migrated from dotnet/linker@f74fcd2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
xUnit will not split the test cases if the parameters to the Theory are complex objects. But if the parameter is a single string it will do it. So using a trick to store a string->object mapping and identify the tests by the string. When the test is executed the object representation is looked up from the string and executed.
It's not perfect, since xUnit doesn't have the same capability as NUnit to fully customize the generated test case name, so the tests show up as (for example):
RequiresCapability(m: "RequiresCapability.TestMethod")But at least this allows running one test case in isolation.
As a followup, we should split the large tests cases into multiple files.
RequiresCapabilityis the first obvious candidate as it has >1500 lines and currently generates 134 test cases for the analyzer. In general the tests should be refactored and split into more files:RequiresCapabilitytests have 3 levels deep nesting currently.RequiresCapability, it's just a single test failure - even if internally it is actually many different failures.