SpecFlow Parallel and non Parallel tests

2019-08-22 12:29发布

问题:

I'm using SpecFlow to automate my web tests and using parallel execution to speed them up.

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?

EDIT-- I am using SpecRun as my test runner

回答1:

I have managed to find a workaround to my issue.

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>