我的项目有一些单元测试。他们都依赖于一些我无法控制的外部服务。这项服务经常下降(回顾Twitter大约在2008年)。目前,如果服务关闭,则测试失败,持续集成服务器将无法构建。我讨厌这个。我想忽略依赖于此设置的测试,并打印警告。取消测试(带警告)
[BeforeScenario]
try
{
connect(server)
}
catch (Exception x)
{
throw new Exception(String.Format("Failed to connect to server {0}", server), x);
}
我该怎么做?我今天恰好在使用SpecFlow,但我也想知道如何从NUnit这样做。
下面是我目前的。没关系。测试被忽略,但构建仍然失败。
[BeforeScenario]
try
{
connect(server)
}
catch (Exception x)
{
throw new SpecFlowCancelTests(String.Format("Failed to connect to server {0}", server), x);
}
感谢,这正是我想要的! –