Skip to content

Commit e1ec988

Browse files
Add description of debugging test unit (#20494)
* Fix minor output * Add Debug tests * Update docs/core/tutorials/testing-library-with-visual-studio-code.md Co-authored-by: David Pine <[email protected]> * Update docs/core/tutorials/testing-library-with-visual-studio-code.md * Add description of debug tests Co-authored-by: David Pine <[email protected]>
1 parent 04f5bc1 commit e1ec988

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ To create the test methods:
114114
Test Run Successful.
115115
Total tests: 3
116116
Passed: 3
117-
Total time: 5.1116 Seconds
117+
Total time: 5.1116 Seconds
118118
```
119119

120120
## Handle test failures
@@ -144,14 +144,14 @@ If you're doing test-driven development (TDD), you write tests first and they fa
144144
Error Message:
145145
Assert.IsFalse failed. Expected for 'Error': false; Actual: True
146146
Stack Trace:
147-
at StringLibraryTest.UnitTest1.TestDoesNotStartWithUpper()
148-
in C:\Projects\ClassLibraryProjects\StringLibraryTest\UnitTest1.cs:line 33
147+
at StringLibraryTest.UnitTest1.TestDoesNotStartWithUpper() in C:\
148+
Projects\ClassLibraryProjects\StringLibraryTest\UnitTest1.cs:line 33
149149
150150
Test Run Failed.
151151
Total tests: 3
152152
Passed: 2
153153
Failed: 1
154-
Total time: 1.7825 Seconds
154+
Total time: 1.7825 Seconds
155155
```
156156

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

169169
The tests pass.
170170

171+
## Debug tests
172+
173+
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**.
174+
175+
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.
176+
171177
## Additional resources
172178

173179
* [Unit testing in .NET Core and .NET Standard](../testing/index.md)

docs/core/tutorials/testing-library-with-visual-studio-mac.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ To test the Release build:
159159

160160
## Debug tests
161161

162-
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.
162+
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.
163+
164+
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.
163165

164166
## Additional resources
165167

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ To test the Release build:
181181
182182
1. Run the unit tests by choosing **Test Run** > **All Tests** from the menu bar. The tests pass.
183183

184+
## Debug tests
185+
186+
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.
187+
188+
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.
189+
184190
## Additional resources
185191

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

0 commit comments

Comments
 (0)