问题描述
我正在使用SpecFlow自动化我的Web测试,并使用并行执行来加速它们.
I'm using SpecFlow to automate my web tests and using parallel execution to speed them up.
我的问题是,如果运行3次但未成功登录,则检查无效密码被拒绝的测试将锁定该用户帐户.
The issue i have is that one test which checks that invalid passwords are rejected will lock the user account if run 3 times without a successful login.
我已将它们设置为随后执行成功的登录,但是并行运行意味着针对多个目标同时运行它们并仍然锁定帐户.
I've set them up to perform a successful login afterwards however running in parallel means against multiple targets they are ran at the same time and still lock the account.
有没有一种方法可以将此测试设置为不并行运行,以使其不会锁定帐户并仍然允许其他帐户并行运行?
Is there a way I can set just this test to not run in parallel so it doesn't lock the account and still allow the others to run in parallel?
编辑-我将SpecRun用作测试运行程序
EDIT--I am using SpecRun as my test runner
推荐答案
我设法找到了解决此问题的方法.
I have managed to find a workaround to my issue.
通过将以下代码放入我的srprofile中,我可以标记希望顺序运行的测试,并且它们只能在特定线程中运行.
By placing the below code in my srprofile I can tag the tests I wish to run sequentially and they are forced to only run in a particular thread.
<TestThreads>
<TestThread id="0">
<TestAffinity>@Sequential | !@Sequential</TestAffinity>
</TestThread>
<TestThread id="1">
<TestAffinity>!@Sequential</TestAffinity>
</TestThread>
<TestThread id="2">
<TestAffinity>!@Sequential</TestAffinity>
</TestThread>
<TestThread id="3">
<TestAffinity>!@Sequential</TestAffinity>
</TestThread>
<TestThread id="4">
<TestAffinity>!@Sequential</TestAffinity>
</TestThread>
<TestThread id="5">
<TestAffinity>!@Sequential</TestAffinity>
</TestThread>
<TestThread id="6">
<TestAffinity>!@Sequential</TestAffinity>
</TestThread>
<TestThread id="7">
<TestAffinity>!@Sequential</TestAffinity>
</TestThread>
</TestThreads>
这篇关于SpecFlow并行和非并行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!