Testfx: No Source Available in Test Explorer

Created on 26 Sep 2017  路  12Comments  路  Source: microsoft/testfx

Description

In the Unit Test Explorer I can see and run a unit test, but when I select the test it displays on the bottom, "No source available"

Steps to reproduce

I created a unit test project, and converted it to use the new project file format with PackageReferences. I added two Nuget packages, MSTest.TestAdapter and MSTest.TestFramework.

Expected behavior

I should be able to double click a test to navigate to the code

Actual behavior

I see a message "No Source Available"

Environment

Visual Studio v15.3.5
MSTest.TestAdapter v1.1.18
MSTest.TestFramework v1.1.18

I may not have properly converted the project to use the new project format. Is there a sample of a Unit Test project which uses PackageReferences (as opposed to packages.config?)

question

Most helpful comment

@johncrim
From doc:

Use of better performant Roslyn APIs instead of reflection based approach on PDBs.

Indicates source info determined by Roslyn APIs, It shouldn't be matter what type the PDB is.

Debug type embedded working for me on 15.5.1. See the below image.

source_info

All 12 comments

@jackbond: I guess the conversion went well because you are able to discover and run tests. There might be something else at play here. Could you turn on TestExplorer diagnostics from Tools -> Options -> Test -> Logging -> Logging Level? Set that to diagnostic and share the logs that show up in the Output->Tests pane with us please.

repro.zip

How about a solution that reproduces the issue?

I've resolved the issue by adding the Microsoft.NET.Test.Sdk Nuget. I skipped adding it originally because its Nuget description reads, "The MSbuild targets and properties for building the .Net core test projects." Perhaps that description could be updated?

@jackbond: Thanks for the repro. This is a new project system based project where the pdbs generated are portable by default. That explains why the Source Information logic fails since it currently only works on full pdbs.

Adding Microsoft.Net.Test.Sdk package brought in the following

<DebugType>Full</DebugType>

ensuring that the scenario works. You could go ahead and keep that package installed(which is added in by default for Unit test templates in the project system).
/cc: @Faizan2304, @smadala for the package description change.

@AbhitejJohn

Thanks for the info. I converted a few more of our unit test projects, and one of them had an AssemblyInitialize attribute. When I ran a test, I got the error below. I haven't been able to recreate the problem in the repro project I sent you, any possible ideas? Thanks.

Method OurClassName.AssemblyInit has wrong signature. Parameter 1 should be of type Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.

@jackbond: Do you have a testsettings file specified for the run? If yes, can you try removing it or replacing with a runsettings instead?

Please reactivate if this is still blocking you.

Is there an issue tracking the fact that the test explorer doesn't work with embedded PDBs?

@johncrim From VS 15.5 test explorer should support it, Source-Information-For-Discovered should solve the embedded PDBs issue.

Thanks @smadala . I've found that VS 15.5 works with portable symbols, but not embedded. The linked document doesn't provide any additional info on support for portable vs embedded symbols.

@johncrim
From doc:

Use of better performant Roslyn APIs instead of reflection based approach on PDBs.

Indicates source info determined by Roslyn APIs, It shouldn't be matter what type the PDB is.

Debug type embedded working for me on 15.5.1. See the below image.

source_info

Just FYI, I had this problem with a .NET Console App targeting full framework, referenced from unit tests. Going to settings and setting Build -> Advanced -> Debugging information to Full fixed the problem.

Was this page helpful?
0 / 5 - 0 ratings