Visual Studio and Nuget based Test Runners/Adapters

后端 未结 1 765
被撕碎了的回忆
被撕碎了的回忆 2021-01-14 14:34

Recently I came to know about the nuget based adapter/runner (http://xunit.github.io/docs/running-tests-in-vs.html)

I was trying to understand how these runners/adap

相关标签:
1条回答
  • 2021-01-14 15:03

    Since this involves a lot of how VS works internally, I don't think you'll get a totally definitive answer. However, to solve the issue you linked to I looked at a bunch of disassembled code, so I have a pretty good idea. Here's how it seems to work:

    1. You build a project that references a package named Sample.TestAdapter
    2. VS copies Sample.TestAdapter directory from packages to %TEMP%\VisualStudioTestExplorerExtensions
    3. Something triggers test discovery - rebuild always does, sometimes incremental builds do too. vstest.console.exe is useful here for debugging.
    4. VS launches vstest.discovery.exe which looks in VisualStudioTestExplorerExtensions for an assembly that implements ITestDiscoverer
    5. If an ITestDiscoverer is found, VS calls it with a list of assemblies that may contain tests
    6. Tests that are discovered are sent back to VS by your test adapter

    So, as far as I can tell it's a pretty simple reflection based plug-in architecture. Hope that helps.

    0 讨论(0)
提交回复
热议问题