在运行时禁用选定的自动化测试
是否可以在运行时禁用选定的自动化测试?
我正在使用 VSTS 和 rhino 模拟,并进行一些需要安装外部依赖项 (MQ) 的集成测试。并非我团队中的所有开发人员都安装了此软件。
目前,所有需要 MQ 的测试都继承自一个基类,该基类检查是否安装了 MQ,如果未安装,则将测试结果设置为不确定。这是有效的,因为它会停止测试运行,但会将测试运行标记为不成功,并且可以隐藏其他失败。
有什么想法吗?
Is is posable to disable selected automated tests at runtime?
I'm using VSTS and rhino mocks and have some intergation tests that require an external dependancy to be installed (MQ). Not all the developers on my team have this installed.
Currently all the tests that require MQ inherit from a base class that checks if MQ is installed and if is not sets the test result to inconclusive. This works as it stops the tests from running, but marks the test run as unsuccseessful and can hide other failures.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
终于解决了这个问题,这就是我所做的。
在我的每个具有 MQ 依赖项的测试类(或方法,如果类中只有少数测试需要 MQ)中,我将以下内容添加到类(或方法) decleration 中,
这将禁用测试,除非您具有条件比较符号 < code>RunMQTests 已清除,该符号未在项目文件中定义,因此默认情况下禁用测试。
为了启用这些测试,开发人员不必记住他们是否安装了 MQ 并添加或删除条件比较符号,我创建了一个自定义构建任务,该任务将告诉我们是否安装了 MQ。
然后我们只需要将任务添加到测试项目文件的顶部即可将其连接到构建过程中。
如果本机安装了 MQ,则在
BeforeBuild
目标中调用新的自定义任务并设置条件比较符号。这允许安装了 MQ 的用户运行我们的 MQ 集成测试,同时不会让未安装 MQ 的用户运行测试失败。
Finaly got aroung to figuring this out, here is what I did.
In each of my test classes (or methods if only a small number of tests in the class require MQ) that had MQ dependancies I added the following to the class (or method) decleration
This disables the tests unless you have the conditional compalation symbol
RunMQTests
decleared, this symbol is not defined in the project files so the tests are disabled by default.To enable these tests with out developers having to remember if they have MQ installed and adding or removing the conditional compalation symbol, I created a custom build task that will tell us if MQ is installed.
Then we just need to hook this up into the build process by adding the task to the top of the test project file.
And call the new custom task in the
BeforeBuild
target and set the conditional compalation symbol if this machine has MQ installed.This lets users that have MQ installed to run our MQ intergration tests, while not failing test runs for users that don't.