我可以使用 VS2010 进行自动化 MSTest 测试吗?
我想让 MSTest (老实说,我会在这一点上采取任何措施)在构建后运行我的测试,然后如果任何测试失败,则生成标准 file(lineno): message
输出Visual Studio 可以识别并允许我直接找到故障点。
或者,如果可能的话,在成功构建后,我希望自动触发“运行解决方案中的所有测试”Visual Studio 命令。
据我所知,这是不可能的。 MSTest 的命令行版本不会生成正确格式的输出(据我所知,NUnit 或 xUnit 也不会生成),因此当我将 MSTest 添加到项目的 Post Build 中时,我仍然需要四处滚动,寻找失败的。只要我记得在构建完成时按 Ctrl-R,A
,IDE 内版本就可以正常工作。
I would like to have MSTest (honestly, I'd take whatever at this point) run my tests post-build, and then if any tests fail, produce the standard file(lineno): message
output that Visual Studio recognizes and allows me to go straight to the failure point.
Or, if possible, then after a successful build I'd like the "Run All Tests in Solution" Visual Studio command to fire automatically.
As far as I can tell, this isn't possible. The commandline version of MSTest does not produce correctly formatted output (and as far as I can tell, neither does NUnit or xUnit), so when I add MSTest to my project's Post Build, I still have to scroll around, looking for the one that failed. The in-IDE version works ok, as long as I remember to hit Ctrl-R,A
when the build finishes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过在项目文件中创建自定义目标而不是使用预烘焙的 PostBuild 目标来获得所需的内容。将类似的内容添加到您的项目文件中,将其编辑为 XML,
您需要正确设置测试程序集的路径或您正在使用的任何其他方法(测试配置文件等),并且您可能需要调整正则表达式,从这里的内存中...
这将运行 mstest,类似于您在 PostBuild 中执行的操作,但增加了 MSBuild(驱动 C# 构建系统的驱动力)检测应视为错误的输出字符串的能力。 CustomWarningRegularExpression 也有一个类似的参数。
如果您想在多个项目之间共享此内容,请查找“MSBuild Imports”
You can get what you are looking for by making a custom target in your project file instead of using the pre-baked PostBuild target. Add something like this right into your project file, editing it as XML,
You'll need to properly set the path to your test assembly or whatever other method you are using (test config file etc.), and you may need to tweak the regex, going from memory here...
This will run mstest similar to how you are probably doing in the PostBuild, but adds in the ability for MSBuild (which is what drives the C# build system) to detect output strings that it should consider errors. There is a similar parameter for a CustomWarningRegularExpression also.
If you want to share this among multiple projects, look up "MSBuild Imports"
我已切换到 xUnit,并使用 对其 MSBuild 单元测试运行程序进行微小更改,我得到了我想要的。
I've switched to xUnit, and with a minor change to their MSBuild unit test runner, I get what I want.