简体   繁体   English

tfs2010 teambuild通宵单元测试已停止完成(由于断言失败?)

[英]tfs2010 teambuild overnight unit tests have stopped completing (due to assertion fail?)

The auto build completes (when 'Disable Tests' is set to true in build definition) but when I enable tests the build doesn't complete. 自动构建完成(在构建定义中将“禁用测试”设置为true时),但是当我启用测试时,构建未完成。 I'm building as Debug/AnyCpu. 我正在构建为Debug / AnyCpu。 I've copy-and-pasted the MSTest line and ran it in a shell on the build server and I got some assertion fails. 我已经复制并粘贴了MSTest行,并在构建服务器上的外壳程序中运行了它,但断言失败了。 Thus, I think the server's waiting for a response to ignore/retry these assertions, does anyone know how I can fix this? 因此,我认为服务器正在等待响应以忽略/重试这些断言,有人知道我该如何解决?

If you want to using assertions during your unit testing, I would recommend using the Unit Test Framework Assert class instead of Debug.Assert. 如果要在单元测试期间使用断言,建议您使用单元测试框架Assert类而不是Debug.Assert。

See this method for more details: 有关更多详细信息,请参见此方法:

http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.assert.fail.aspx http://msdn.microsoft.com/zh-CN/library/microsoft.visualstudio.testtools.unittesting.assert.fail.aspx

You have different ways to assert (AreEqual, AreNotEqual, IsTrue, etc.). 您有不同的断言方式(AreEqual,AreNotEqual,IsTrue等)。

Hope this helps. 希望这可以帮助。

使用服务器上的发布版本进行单元测试-它将没有任何断言。

What do you mean build doesn't complete? 您的意思是构建没有完成? The build log will tell you what is the most recent action. 构建日志将告诉您最新的操作。 You might want to set the logging level to detailed for the build to see more information. 您可能希望将日志记录级别设置为“详细”,以使构建查看更多信息。 Also one issue might be that you have configured the build to fail if tests fail. 还有一个问题可能是您已将构建配置为在测试失败时失败。 In that case you could add Ignore attribute into those tests: 在这种情况下,您可以将“忽略”属性添加到这些测试中:

[TestMethod]
[Ignore]
public void TestMethodThatFails()

Of course you should fix those tests rather than ignore them but that is not the subject of this question. 当然,您应该修复这些测试而不是忽略它们,但这不是此问题的主题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM