MSTest的:如何增加测试时间 [英] MSTest: how to increase test time

查看:272
本文介绍了MSTest的:如何增加测试时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个测试,需要更多的工作,然后一分钟(VS2008,MSTest的,测试从VisualStudio中推出):

I have one test that needs to work more then 1 minute (VS2008, MSTest, tests are launched from the 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);
    }

本试验在运行模式下完成了测试Login_ExpirationFail_Test突破的执行超时时间。错误信息,在调试 - 它正常工作

This test is finished in "Run" mode with "Test 'Login_ExpirationFail_Test' exceeded execution timeout period." error message, in "Debug" - it works fine.

我看到挂在命令行启动测试几个类似的问题。

I saw few similar problems linked to launching tests from the command line.

我如何能得到我的测试可行的运行模式?

How could I get my test workable in "Run" mode?

感谢。

推荐答案

答案很简单:属性值应该是一个常数,而不是前pression

Answer is very simple: attribute value should be a constant, not an expression.

修改

[Timeout(10*60*1000)]

[Timeout(600000)]

解决的问题。

resolved an issue.

编辑:发表评论我要提醒我注意一个错误,我的回答原来做了回答(写了60000作为超时值)。在我的源$ C ​​$ C我有600万,而价值帮助。答案最近已得到纠正

Comment to the answer brought to my attention a mistake I've done originally in the answer (wrote "60000" as timeout value). In my source code I have 6000000 and that value helped. the answer was corrected recently

这篇关于MSTest的:如何增加测试时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆