我有一个测试需要工作超过1分钟(VS2008,MSTest,从VisualStudio启动测试):
const int TestTimeout = 1; [TestMethod] [Timeout(10*60*1000)] // 10 minutes public void Login_ExpirationFail_test() { IAuthenticationParameters parameters = new AuthenticationParameters(...); LdapAuthentication auth1 = new LdapAuthentication(); IAuthenticationLoginResult res = auth1.Login(parameters); Assert.IsNotNull(res); Assert.IsFalse(string.IsNullOrEmpty(res.SessionId)); const int AdditionalMilisecodns = 400; System.Threading.Thread.Sleep((TestTimeout * 1000 + AdditionalMilisecodns) * 60); LdapAuthentication auth2 = new LdapAuthentication(); auth2.CheckTicket(res.SessionId); }
此测试在“运行”模式下以“Test”Login_ExpirationFail_Test“超出执行超时时间”完成。错误消息,在“调试” – 它工作正常。
我看到与命令行启动测试有关的几个类似的问题。
如何让我的测试在“运行”模式下可行?
谢谢。
答案很简单:属性值应该是一个常量,而不是一个表达式。
更改
[Timeout(10*60*1000)]
至
[Timeout(600000)]
编辑:对答案的评论引起了我的注意,我最初在答案中做了一个错误(写为“60000”作为超时值)。在我的源代码中,我有6000000,这个价值有所帮助。答案最近更正了
原文地址:https://www.jb51.cc/javaschema/282209.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。