[ACCEPTED]-run tests in mstest without compiling/building-mstest

Accepted answer
Score: 12

Any time your code changes and you run your 32 test it is going to do a build... so technically 31 you can run your test over and over again 30 and they will only build the first time, but 29 once you run your test why would you run 28 them again without making a code change?

Couple 27 of things that I use that make your test 26 run faster are:

  1. Check the box for "Only 25 build startup projects and dependencies 24 on Run", located Options->Projects 23 and Solution->Build and Run.

  2. Learn the 22 short cut keys
    a. "Ctrl+R, T" Runs 21 test in current context, so if your cursor 20 is inside a test method it will only run 19 that test, but when you do it inside of 18 a non test class it will run all of your 17 test.
    b. "Crtl+R, Ctrl+T" Debug 16 test same except debug.
    c. Others can be 15 found here, those are 2008 if you need to reference 14 others you can find them via google.

  3. Make 13 sure your test are not calling the database 12 or other time intensive resources, use mocking 11 and stubbing.

  4. Run only small sets of test, ie 10 if I am working in a service class I run 9 only the service class test.

Edit: Reading your 8 question again if you want to build and 7 not from a test you can just go to the menu 6 and click Build->Build Solution or press 5 F6. Also it would be helpful if you indicated 4 which version of visual studio you are using 3 because 2010 is different in the sense that 2 you have to click refresh. Either way are 1 you able to clarify?

Score: 3

This is an old question, but I keep seeing 11 people ask it and the issue is still true 10 in VS2017, and it's also true of other test 9 frameworks (Xunit, etc) run from within 8 VS.

I don't know how to make VS stop building 7 all the time. But I do know how to circumvent 6 the compile - run your tests from a console 5 runner, not from within VS. If you're using 4 ReSharper, it has one.

If you aren't using 3 ReSharper, for MSTest, you can start here. https://msdn.microsoft.com/en-us/library/ms182489.aspx

If 2 you aren't using ReSharper, for XUnit, you 1 can start here. https://xunit.github.io/docs/getting-started-desktop.html#add-xunit-runner-ref

Score: 2

Any changes to source code cause compilation, because 5 in order to run tests VS needs up to date 4 DLL with tests.

If you have already compiled 3 project then you can run test multiple times 2 without compilation.

PS: I run MSTest using 1 TestDriven.NET as for me it is faster.

More Related questions