Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug unit tests in Visual Studio Code

As per title, how do I debug xunit tests using Visual Studio Code?

I can already run xunit from the command line using dnx test but I would like to debug these tests now.

I'm on Mac.

Thanks.

Update: here is the output of dnvm and dnx:

dnx test -debug
Debug support is not available in DNX Core.

dnvm list -detailed

Active Version              Runtime Architecture OperatingSystem Alias   Location
------ -------              ------- ------------ --------------- -----   --------
  *    1.0.0-rc1-update1    coreclr x64          darwin                  ~/.dnx/runtimes
       1.0.0-rc1-update1    mono                 linux/osx       default ~/.dnx/runtimes

dnvm version
1.0.0-rc2-15546
like image 602
AndyD Avatar asked Dec 19 '15 13:12

AndyD


People also ask

Can you debug a unit test code?

Debug and analyze unit tests with Test ExplorerYou can use Test Explorer to start a debugging session for your tests. Stepping through your code with the Visual Studio debugger seamlessly takes you back and forth between the unit tests and the project under test.

How do I debug a single unit test in Visual Studio?

According to this answer (By Jon Skeet no less) it is possible in Visual studio natively too. To debug a single test: Click on a test method name, then press Ctrl+R, Ctrl+T.

How do you debug a test case?

To debug a failed test case you should: check that the input data is correct (open the test case to view and/or update the base level attribute values) check that the expected results are correct (in the Test Report, click on the expected result to view and/or update the expected results for that attribute)


1 Answers

dnx -p path\to\project test -debug

-debug should do it.

You can find that a couple ways

  1. dnx -p ./folder test -?

-the -? gives you all the help for the command 'test'

  1. or read through code...

https://github.com/xunit/dnx.xunit/blob/master/src/xunit.runner.dnx/CommandLine.cs

Best of luck.

like image 81
mikeg Avatar answered Sep 18 '22 17:09

mikeg