Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
374 views
in Technique[技术] by (71.8m points)

tdd - How to speed up Test-Driven Development in Visual Studio

Unlike many questions on this topic, this is not about speeding up the nature of my tests. I'm referring to pure unit tests which are already fast (< 0.5 sec), but for which the surrounding tooling (Visual Studio 2019's test framework) is painfully slow. I want fast TDD cycles.

Scenario: I'm exercising some simple code in a class library (.NET Framework 4.7.2) with a unit test project (also NF 4.7.2, using the latest (v2.1.2) nuget packages for MSTest.TestAdapter and MSTest.TestFramework). In my whole solution I have 2083 tests.

Without changing any code in the code under test, then making a trivial change in the test code and hitting CTRL-R, T (run single test), the whole duration from start to finish is 18 seconds. Here's the breakdown:

3.5 sec build time 0.5 sec test execution time 18 sec total time which leaves 14 seconds where Test Explorer is just spinning its tires.

I understand the virtues of the whole "red-green-refactor" style of development, but with 18 seconds of dead time every time I make a tiny change and want to test it, I find that it's a productivity killer; can't get into a good grove.

Any ideas how to eliminate that 14 seconds test framework time?

Edit

The console approach looks promising (fast execution), but it is more cumbersome (separate windows, copying'n'pasting long file paths, separate build step, etc). If someone could describe how they achieve really fast, effortless TDD cycles with .NET, that would be appreciated.

Edit 2

I discovered the TestDriven.NET VS extension, which is incredibly fast (completes almost instantly). However, it seems buggy or incomplete (for example, doesn't respect the [ExpectedException] attribute). The interesting thing is that on the project website it states

The tests are launched by a test execution engine running as an external process. This test process is kept alive in order to improve execution times on subsequent runs

I wonder if there's a simple way to instruct vanilla VS to keep its test process alive, and if that would achieve the same speeds.

question from:https://stackoverflow.com/questions/65600383/how-to-speed-up-test-driven-development-in-visual-studio

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...