Domanda

When working on larger projects, it can take at least 10 seconds to compile and start the unit test framework. Are there effective ways to reduce the feedback loop time? I intend to make just small changes in one unit test class and one other class between test runs.

I considered some other approaches. I do not see any way to compile and run a single test class and dependencies. I could increase the number of projects in the solution so that each assembly takes less time to compile, but that causes other issues. NCrunch appears to reduce the need to manually run tests, but it still compiles full assemblies.

Clarification: The 10 seconds included time to compile the unit test class and the class under test. My issue with NCrunch may have been because of a less powerful computer.

È stato utile?

Soluzione

You'd have to put each test class in a separate assembly - an assembly is effectively the unit of compilation. If it's taking 10 seconds to recompile after just a change to a test class, that suggests that either you've got too many tests in one assembly, or you've got a very slow machine. It could well be that getting a better machine (or improving the existing one with more memory or an SSD) is the best way forward.

I use NCrunch myself, and although it still compiles full assemblies, the fact that it's doing it in the background means that usually by the time I've taken a mental breath, the tests have rebuilt and are running. NCrunch works well if you've got multiple processors and a ramdisk, by the way - you can set where it builds, and also how many processors it can use.

If you've only considered NCrunch (or The Mighty Moose etc - similar stuff) but not actually tried it, you should give it a go before assuming it won't be fast enough for you.

Altri suggerimenti

You might check out AutoTest.Net, which is an add-on for Visual Studio that runs your unit tests in the background as you write your code.

This way you can treat your unit tests more like compiler errors / warnings and get relatively real-time feedback.

Declarative unit tests would effectively zero out the compilation time, but only if your architecture permits. For example, moving the unit tests to database worked well for us in a large-scale project.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top