Skip to content

Commit

Permalink
Add description of debugging test unit (#20494)
Browse files Browse the repository at this point in the history
* Fix minor output

* Add Debug tests

* Update docs/core/tutorials/testing-library-with-visual-studio-code.md

Co-authored-by: David Pine <david.pine@microsoft.com>

* Update docs/core/tutorials/testing-library-with-visual-studio-code.md

* Add description of debug tests

Co-authored-by: David Pine <david.pine@microsoft.com>
  • Loading branch information
johypark and IEvangelist committed Sep 23, 2020
1 parent 04f5bc1 commit e1ec988
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
14 changes: 10 additions & 4 deletions docs/core/tutorials/testing-library-with-visual-studio-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ To create the test methods:
Test Run Successful.
Total tests: 3
Passed: 3
Total time: 5.1116 Seconds
Total time: 5.1116 Seconds
```

## Handle test failures
Expand Down Expand Up @@ -144,14 +144,14 @@ If you're doing test-driven development (TDD), you write tests first and they fa
Error Message:
Assert.IsFalse failed. Expected for 'Error': false; Actual: True
Stack Trace:
at StringLibraryTest.UnitTest1.TestDoesNotStartWithUpper()
in C:\Projects\ClassLibraryProjects\StringLibraryTest\UnitTest1.cs:line 33
at StringLibraryTest.UnitTest1.TestDoesNotStartWithUpper() in C:\
Projects\ClassLibraryProjects\StringLibraryTest\UnitTest1.cs:line 33

Test Run Failed.
Total tests: 3
Passed: 2
Failed: 1
Total time: 1.7825 Seconds
Total time: 1.7825 Seconds
```

1. Remove the string "Error" that you added in step 1. Rerun the test and the tests pass.
Expand All @@ -168,6 +168,12 @@ Now that the tests have all passed when running the Debug build of the library,

The tests pass.

## Debug tests

If you're using Visual Studio Code as your IDE, you can use the same process shown in [Debug a .NET Core console application using Visual Studio Code](debugging-with-visual-studio-code.md) to debug code using your unit test project. Instead of starting the *ShowCase* app project, open *StringLibraryTest/UnitTest1.cs*, and select **Run All Tests** between lines 7 and 8. If you're unable to find it, press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> to open the command palette and enter **Reload Window**.

Visual Studio Code starts the test project with the debugger attached. Execution will stop at any breakpoint you've added to the test project or the underlying library code.

## Additional resources

* [Unit testing in .NET Core and .NET Standard](../testing/index.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ To test the Release build:

## Debug tests

You can use the same process shown in [Tutorial: Debug a .NET Core console application using Visual Studio for Mac](debugging-with-visual-studio-mac.md) to debug code using your unit test project. Instead of starting the ShowCase app project, <kbd>ctrl</kbd>-click the **StringLibraryTests** project, and select **Start Debugging Project** from the context menu. Visual Studio starts the test project with the debugger attached. Execution will stop at any breakpoint you've added to the test project or the underlying library code.
If you're using Visual Studio for Mac as your IDE, you can use the same process shown in [Tutorial: Debug a .NET Core console application using Visual Studio for Mac](debugging-with-visual-studio-mac.md) to debug code using your unit test project. Instead of starting the *ShowCase* app project, <kbd>ctrl</kbd>-click the **StringLibraryTests** project, and select **Start Debugging Project** from the context menu.

Visual Studio starts the test project with the debugger attached. Execution will stop at any breakpoint you've added to the test project or the underlying library code.

## Additional resources

Expand Down
6 changes: 6 additions & 0 deletions docs/core/tutorials/testing-library-with-visual-studio.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ To test the Release build:

1. Run the unit tests by choosing **Test Run** > **All Tests** from the menu bar. The tests pass.

## Debug tests

If you're using Visual Studio as your IDE, you can use the same process shown in [Tutorial: Debug a .NET Core console application using Visual Studio](debugging-with-visual-studio.md) to debug code using your unit test project. Instead of starting the *ShowCase* app project, right-click the **StringLibraryTests** project, and select **Debug Tests** from the context menu.

Visual Studio starts the test project with the debugger attached. Execution will stop at any breakpoint you've added to the test project or the underlying library code.

## Additional resources

* [Unit test basics - Visual Studio](/visualstudio/test/unit-test-basics)
Expand Down

0 comments on commit e1ec988

Please sign in to comment.