Tired of slow, long-running unit/integration test suites? Want to speed up your feedback cycle while coding? Me too.
At my current employment I am working with by far the largest Visual Studio solution that I have ever encountered and some of the tests run very slowly. I like a rapid feedback loop: Write a few lines of code, build, run tests, repeat all day. Unfortunately some tests are fast running, some are slow. Fortunately the team I am on has segregated their automated tests using TestCategory attributes with names UnitTest andIntegrationTest.
Although it is a bit unintuitive, you can group your tests according to these attributes within the test runner built into Visual Studio 2012. Simply open the top menu Test->Windows->Test Explorer
… and click the little icon shown in the screen capture. The key point to remember is that “Traits” equals “Test Attribute Names.”
Also this giant solution at work is fairly 3D/Mathematical in nature and as such, many of the unit tests run more slowly than the integration tests, so a further handy tip is to run the tests once, and then group them by Duration, for subsequent test runs while you have VS open. This way I can enter my rapid code writing/feedback loop, only running the tests which execute quickly.
Then, I can run the entire suite prior to committing any code which, if broken, might hinder the efforts of my teammates. Provided that your integration tests can be run on demand without any special setup, it is nice to also have the reassurance that they are functioning along with your unit tests, as long as you’re primarily focused on the vast majority of tests that run very quickly.