且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在mbUnit中有条件地忽略测试?

更新时间:2022-06-15 21:45:45

创建TestDecoratorAttribute的子类,并重写Initialize()方法以检查IsDBOnline,如果为false则调用Assert.Inconclusive().

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

获得类似效果的另一种方法是在使用Db的测试中添加[Category]属性,然后在生产环境中运行测试时将其过滤掉.

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.