-
Notifications
You must be signed in to change notification settings - Fork 754
/
InAppDomainParallelExecution.feature
122 lines (108 loc) · 3.58 KB
/
InAppDomainParallelExecution.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
@xUnit @NUnit3 @MSTest
Feature: In-AppDomain Parallel Execution
Background:
Given there is a SpecFlow project
And parallel execution is enabled
And the following binding class
"""
using TechTalk.SpecFlow;
using TechTalk.SpecFlow.Tracing;
[Binding]
public class TraceSteps
{
private readonly ITraceListener _traceListener;
private readonly ITestRunner _testRunner;
public TraceSteps(ITraceListener traceListener, ITestRunner testRunner)
{
_traceListener = traceListener;
_testRunner = testRunner;
}
public static int startIndex = 0;
[When(@"I do something")]
void WhenIDoSomething()
{
var currentStartIndex = System.Threading.Interlocked.Increment(ref startIndex);
_traceListener.WriteTestOutput($"Start index: {currentStartIndex}, Worker: {_testRunner.TestWorkerId}");
System.Threading.Tasks.Task.Delay(500).Wait();
var afterStartIndex = startIndex;
if (afterStartIndex == currentStartIndex)
{
_traceListener.WriteTestOutput("Was not parallel");
}
else
{
_traceListener.WriteTestOutput("Was parallel");
}
}
}
"""
And there is a feature file in the project as
"""
Feature: Feature 1
Scenario Outline: Simple Scenario Outline
When I do something
Examples:
| Count |
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
"""
And there is a feature file in the project as
"""
Feature: Feature 2
Scenario Outline: Simple Scenario Outline
When I do something
Examples:
| Count |
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
"""
Scenario: Precondition: Tests run parallel
When I execute the tests
Then the execution log should contain text 'Was parallel'
Scenario: Tests should be processed parallel without failure
When I execute the tests
Then the execution log should contain text 'Was parallel'
And the execution summary should contain
| Total | Succeeded |
| 10 | 10 |
Scenario Outline: Before/After TestRun hook should only be executed once
Given a hook 'HookFor<event>' for '<event>'
When I execute the tests
Then the execution log should contain text 'Was parallel'
And the hook 'HookFor<event>' is executed once
Examples:
| event |
| BeforeTestRun |
| AfterTestRun |
Scenario Outline: Current context cannot be used in multi-threaded execution
Given there is a feature file in the project as
"""
Feature: Feature with <context>.Current
Scenario: Simple Scenario
When I use <context>.Current
"""
And the following step definition
"""
[When(@"I use <context>.Current")]
public void WhenIUseContextCurrent()
{
System.Threading.Thread.Sleep(200);
Console.WriteLine(<context>.Current);
}
"""
When I execute the tests
Then the execution log should contain text 'Was parallel'
And the execution summary should contain
| Failed |
| 1 |
Examples:
| context |
| ScenarioContext |
| FeatureContext |
| ScenarioStepContext |