在mstest中运行测试而无需编译/构建 [英] run tests in mstest without compiling/building

查看:96
本文介绍了在mstest中运行测试而无需编译/构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有办法吗?每次开始测试时都必须等待构建吗?我想从Visual Studio而不是从测试构建

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

谢谢

推荐答案

每当您的代码更改并运行测试时,它将进行构建...因此从技术上讲,您可以一次又一次地运行测试,并且它们只会是第一次构建,但是一旦运行测试,为什么又要在不进行代码更改的情况下再次运行它们?

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. 选中仅构建启动项目及其对运行的依赖项"复选框,位于选项->项目和解决方案->构建并运行.

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

了解快捷键
"Ctrl + R,T"在当前上下文中运行测试,因此,如果光标在测试方法内部,它将仅运行该测试,但是在非测试类内部进行时,它将运行所有测试.
b.除调试外,"Crtl + R,Ctrl + T"调试测试相同.
c.可以在>此处找到,那是2008年,如果您需要引用其他人,则可以通过google找到它们.

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.

确保测试未调用数据库或其他耗时的资源,请使用模拟和存根.

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

仅运行少量测试,即,如果我在服务类中工作,则仅运行服务类测试.

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

如果您要构建而不是从测试中再次阅读您的问题,则可以转到菜单,然后单击构建"->构建解决方案"或按F6.如果您指出要使用哪个版本的Visual Studio,也会有所帮助,因为2010年在必须单击刷新的意义上有所不同.哪种方式都可以澄清?

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?

这篇关于在mstest中运行测试而无需编译/构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆