tags:

views:

204

answers:

2

is there a way? do I have to wait for building every time I start the test? I want to build from visual studio not from test

thanks

+2  A: 

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

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

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

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

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

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

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

J.13.L
You might run them again if you weren't expecting an error but had one, or you had an error and your debug point missed it, or something along those lines.
AHungerArtist
That could be true... Run once see error, Then debug to step through. I didn't think of that scenario.
J.13.L
I am using Visual Studio 2008.
Marko
Hm, it is strange...I tried now to run tests, I haven't used MSTest for some time(switched to NUnit) and I can see that is not build project every time, just once at the start. The same is when I build project manually and then start tests. But it was not like that when I've asked question? Is this came with an update or something?...it is very strange...
Marko
+1  A: 

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

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

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

Pavlo Neyman