Share via

How do I move from Tests Explorer to my code using Go To Code?

Daniel Shitrit 0 Reputation points
2025-12-19T05:54:17.3533333+00:00

Hi,

Please look on:

https://app.screencast.com/M0S7MDU6bVP9T

When test failed, I right click on tests and pressed "Go To Test", but is not working ? why ?

Thanks in advance,

Developer technologies | Visual Studio | Testing
0 comments No comments

3 answers

Sort by: Most helpful
  1. Varsha Dundigalla(INFOSYS LIMITED) 4,785 Reputation points Microsoft External Staff
    2025-12-29T15:38:05.1766667+00:00

    Thank you for reaching out.
    The issue is not that the test or framework is wrong. The tests are running and failing correctly, which means Visual Studio can discover and execute them.

    The real problem is that Visual Studio is unable to link the test result shown in Test Explorer back to the actual test file in the project. When you click Go to Test or Go to Code, Visual Studio does not know which source file to open, so nothing happens.

    This link between the test result and the source file is created during build and test discovery. If that information is missing, outdated, or not refreshed, Test Explorer can still show and run tests, but navigation to the test code will not work.

    So, the issue is only with navigation from Test Explorer to the test source, not with running the tests themselves or with xUnit.

    Reference:

    1. Test Explorer – Run unit tests and navigate to code https://dori-uw-1.kuma-moon.com/visualstudio/test/run-unit-tests-with-test-explorer (Explains that Test Explorer relies on test discovery metadata to link test results back to source files for navigation.)
    2. Debug symbols (PDB files) and source navigation https://dori-uw-1.kuma-moon.com/visualstudio/debugger/specify-symbol-dot-pdb-and-source-files-in-the-visual-studio-debugger (Explains that Visual Studio uses symbols to map execution results back to source code.)

    Please let us know if you require any further assistance, we’re happy to help. If you found this information useful, kindly mark this as "Accept Answer". So that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    1 person found this answer helpful.

  2. Susmitha T (INFOSYS LIMITED) 2,690 Reputation points Microsoft External Staff
    2025-12-19T09:25:28.14+00:00

    Thank you for reaching out!

    Reason: "Go to Test/ Go To code" doesn't work when debug symbols or the test adapter doesn't loaded correctly, or when Test Explorer cache is corrupted.

     Fix: 

    Switch to Debug configuration

    Clean and rebuild the solution

    1. Ensure the correct test adapter (MSTest/Nunit/xUnit)

    Close Visual Studio and reopen it, then rerun tests

     
    After this, Go to Test should navigate to the test code.

     

    Let me know if you need any further help with this. I will be happy to assist.
    If you find this helpful, Kindly mark the provided solution as "Accept Answer", so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    1 person found this answer helpful.

  3. Q&A Assist
    2025-12-19T05:54:28.1733333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To move from Test Explorer to your code using the "Go To Test" feature in Visual Studio, you typically right-click on the test that has failed and select "Go To Test". This should navigate you directly to the corresponding test code. If this is not working, it could be due to a few reasons:

    1. Test Not Found: Ensure that the test is correctly associated with the code. If the test is not properly linked to the code, the navigation may not function as expected.
    2. Visual Studio Configuration: Sometimes, settings or extensions in Visual Studio can interfere with navigation features. Check if any extensions are affecting this functionality.
    3. Visual Studio Version: Ensure you are using a version of Visual Studio that supports this feature. Updates or patches may also resolve any bugs related to navigation.

    If you continue to experience issues, consider checking the Visual Studio documentation or forums for troubleshooting specific to your version and setup.


    References:

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.