Can I use breakpoints (as during debugging) with “unit testing”?

I walk through the FrontStore series on TDD in MVC ( Part 3 by Rob Conery / ASP.NET). The testing I'm worried about is CatalogRepository_Each_Category_Contains_5_Products () . Until I got to this test, everything was fine. Now I went through every line that this test does (including the test itself, TestCatalogRepository, ...). I also compared my code with Rob's code, but the test continues to fail.

I also checked the source code from CodePlex, this test was not there.

Now, I wonder if I can put a breakpoint somewhere to check the local values ​​when running the test? If not, something like that?

Thanks for the help.

+3
source share
3 answers

Debugging tests should be exactly the same as debugging your code - put a breakpoint and run the test when debugging (in MSTest ctrl + R, ctrl + T).

+6
source

Depending on you testrunner (Nunit or VS) you run the test in debug mode (VS) or run testrunner and attach testrunner (nunit) to the processes

+1
source

Another approach would be to create unit tests that act as control points. This will require SUT refactoring.

0
source

Source: https://habr.com/ru/post/1744102/


All Articles