run tests in mstest without compiling/building

我们两清 提交于 2020-01-13 08:09:57

问题


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


回答1:


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?




回答2:


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.




回答3:


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

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

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

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



来源:https://stackoverflow.com/questions/720417/run-tests-in-mstest-without-compiling-building

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!