How do I ignore a test conditionally in mbUnit?

六眼飞鱼酱① 提交于 2019-12-10 23:25:03

问题


I'm using TeamCity to do automated builds of test and production. TeamCity runs our mbUnit 3.1 tests at the end of the process with Gallio.

When running the test build, Gallio should try to execute tests against the test database server. However, when running a production build, these tests should not be run because TeamCity can't access the production database server (and if even if the production database was available, many tests would fail with unreleased code).

How can I mark a test so that it gets ignored in mbUnit based on a boolean value such as IsDBOnline?


回答1:


Create a subclass of TestDecoratorAttribute and override the Initialize() method to check IsDBOnline and call Assert.Inconclusive() if false.

Another way to achieve a similar effect is to add a [Category] attribute to the tests that use the Db and then filter them out when running the tests on production.



来源:https://stackoverflow.com/questions/1279175/how-do-i-ignore-a-test-conditionally-in-mbunit

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