No source available for [Fact] in base class in another assembly
We've recently migrated to xUnit from MSTest and ran into problems with test discovery in Visual Studio 16.7 (and other IDEs using the VS runner).
When [Fact] is declared in an abstract base class, which is then derived in a specific class containing tests, it is always discovered. However, the source information on the test cases shown in VS is not correct when the base class is in a different assembly than the derived class.
See the attached solution. XUnitBaseFactVisibilityTest.zip
There are 5 tests in 2 assemblies and all are discovered:
- BaseLibrary
- ReferencedSharedTests.TestWithNameInBothAssemblies shown in LocalTests class, source shown in LocalSharedTests.cs. Incorrect, source should be in ReferencedSharedTests.cs.
- ReferencedSharedTests.TestNameOnlyInBaseAssembly shown in LocalTests class, source shown as not available. Incorrect, Source should be in ReferencedSharedTests.cs.
- TestLibrary
- LocalSharedTests.TestWithNameInBothAssemblies shown in LocalTests class, source shown in LocalSharedTests.cs. Correct.
- LocalTests.TestInDerivedClass shown in LocalTests class, source shown in LocalSharedTests.cs. Correct.
- ReferencedTests.TestInDerivedClass shown in ReferencedTests class, source shown in ReferencedTests.cs. Correct.
Neither of the tests in BaseLibrary is correctly shown and the second failure can be quite misleading and Rider will not show source code for both TestWithNameInBothAssemblies tests .
I was unable to locate the source of this behavior myself. Is there any way to make this work correctly?