vstest
vstest copied to clipboard
Missing source information (CodeFilePath, LineNumber) in discovered test cases for .NET Core (3.x?) projects with "Full" PDB (instead of "Portable" PDB)
Description
Hi,
I'm using VsTestConsoleWrapper API to discover test cases.
When the test assembly is compiled to .NET Core (3.x?) and is configured to produce Full PDB instead of default Portable PDB, the discovered TestCase have null CodeFilePath and LineNumber is -1.
After switching to Portable PDB the CodeFilePath and LineNumber are correct.
As you can see in next comment, it looks like a regression, because it works correctly if unit test project targets .net core 2.1
Steps to reproduce
I'm attaching:
- ConsoleApp5.zip - project with unit tests
- VstestTest.zip - project which uses VsTestConsoleWrapper to discover and display test cases
Reproduction:
- unpack ConsoleApp5, verify unit test projects use Full PDBs, compile
- unpack VstestTest, compile
- download microsoft.testplatform nuget, unpack
- run VstestTest, for example:
D:\dv.scripts\vstest_repro\VstestTest\VstestTest\bin\Debug\VstestTest.exe ^
D:\dv.scripts\vstest_repro\microsoft.testplatform.16.4.0\tools\net451\Common7\IDE\Extensions\TestPlatform\vstest.console.exe ^
D:\dv.scripts\vstest_repro\ConsoleApp5\UnitTestProject1\bin\Debug\netcoreapp3.1\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll ^
D:\dv.scripts\vstest_repro\ConsoleApp5\UnitTestProject1\bin\Debug\netcoreapp3.1\UnitTestProject1.dll
- observe missing CodeFilePath and incorrect LineNumber in output
- modify ConsoleApp5 to use Portable PDB, recompile it, rerun VstestTest, observe correct values
Expected behavior
DisplayName=TestMethod1
CodeFilePath=D:\dv.scripts\vstest_repro\ConsoleApp5\UnitTestProject1\UnitTest1.cs
LineNumber=11
Actual behavior
DisplayName=TestMethod1
CodeFilePath=
LineNumber=-1
Diagnostic logs
I'm attaching:
- logs.zip - vstest logs and output
Environment
I have used vstest from nuget packages microsoft.testplatform.16.4.0 and microsoft.testplatform.16.5.0-preview-20191115-01.
I'm testing this on Windows 10.
It works correctly when tested project targets .net core 2.1 (2.x?) - source information is present for both portable and full PDB. So this looks like a regression.
I may be wrong, but I think I read somewhere about DIA update in .net core 3.x - I may be wrong though.
Attaching
- ConsoleApp6.zip - project with unit tests, targetting .net core 2.1
Hello, how is it going? If you have any questions, please ask.
I can confirm this issue as well. Currently, it is a blocker for me. Can anybody help with that?
@singhsarab @mayankbansal018 any update on this?
@vritant24 weren't you looking at something similar recently? maybe you have some insight into this?
I'm working on a test logger to use with GitHub Actions and just ran into this issue. Both CodeFilePath
and LineNumber
are empty for my .net core 3.1 project. I tried setting up a .net core 2.1 and 2.2 project but I'm seeing the issue there too. I found that xunit 2.3.x will give -1
for LineNumber
while 2.4.x gives 0
, otherwise it's always the same results no matter what combo of packages & sdk I use.
@nohwnd Assigning you also on this one as it seems to be related to #3417 where you are assigned.
I could not repro on 17.6.0 test platform that the source information would switch between collecting and not collecting when changing full or portable pdbs. Collecting source info is off by default (for performance). You can force it by configuration. It is enabled by default when using interactive mode (design mode).
vstest.console.exe MSTest2.dll --listtests -- RunConfiguration.CollectSourceInformation=true