Skip to content

Commit ac1519b

Browse files
committed
Parallel Tests: add 4th feature, set workers to 2
1 parent a6d144e commit ac1519b

File tree

7 files changed

+146
-8
lines changed

7 files changed

+146
-8
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Feature: Addition4
2+
3+
The calculator functions related to addition,
4+
that is denoted with the '+' operator.
5+
6+
@core
7+
Rule: Positive numbers can be added
8+
9+
Scenario: Add two numbers
10+
This is the most common use-case:
11+
people often sum two numbers.
12+
13+
Given the first number is 50
14+
And the second number is 70
15+
When the two numbers are added
16+
Then the result should be 120
17+
18+
@commutativity
19+
Scenario: Addition is commutative
20+
Given the first number is 70
21+
And the second number is 50
22+
When the two numbers are added
23+
Then the result should be 120
24+
25+
Rule: Non-positive numbers can be added
26+
27+
@edgeCase
28+
Scenario Outline: Add zeros
29+
Given the first number is <first>
30+
And the second number is <second>
31+
When the two numbers are added
32+
Then the result should be <result>
33+
Examples:
34+
| description | first | second | result |
35+
| #1 | 0 | 0 | 0 |
36+
| #2 | 0 | 42 | 42 |
37+
| #3 | 42 | 0 | 42 |
38+
39+
Scenario: Add negatives
40+
Given the entered numbers are
41+
| number |
42+
| -5 |
43+
| -7 |
44+
When the two numbers are added
45+
Then the result should be -12
46+
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
22

33
// class-level parallel
4-
[assembly: Parallelize(Workers = 4, Scope = ExecutionScope.ClassLevel)]
4+
//[assembly: Parallelize(Workers = 2, Scope = ExecutionScope.ClassLevel)]
55

66
// method-level parallel
7-
//[assembly: Parallelize(Workers = 4, Scope = ExecutionScope.MethodLevel)]
7+
[assembly: Parallelize(Workers = 2, Scope = ExecutionScope.MethodLevel)]
88

99
// no parallel
1010
//[assembly: DoNotParallelize]
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Feature: Addition4
2+
3+
The calculator functions related to addition,
4+
that is denoted with the '+' operator.
5+
6+
@core
7+
Rule: Positive numbers can be added
8+
9+
Scenario: Add two numbers
10+
This is the most common use-case:
11+
people often sum two numbers.
12+
13+
Given the first number is 50
14+
And the second number is 70
15+
When the two numbers are added
16+
Then the result should be 120
17+
18+
@commutativity
19+
Scenario: Addition is commutative
20+
Given the first number is 70
21+
And the second number is 50
22+
When the two numbers are added
23+
Then the result should be 120
24+
25+
Rule: Non-positive numbers can be added
26+
27+
@edgeCase
28+
Scenario Outline: Add zeros
29+
Given the first number is <first>
30+
And the second number is <second>
31+
When the two numbers are added
32+
Then the result should be <result>
33+
Examples:
34+
| description | first | second | result |
35+
| #1 | 0 | 0 | 0 |
36+
| #2 | 0 | 42 | 42 |
37+
| #3 | 42 | 0 | 42 |
38+
39+
Scenario: Add negatives
40+
Given the entered numbers are
41+
| number |
42+
| -5 |
43+
| -7 |
44+
When the two numbers are added
45+
Then the result should be -12
46+
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// class-level parallel
2-
[assembly: NUnit.Framework.Parallelizable(NUnit.Framework.ParallelScope.Fixtures)]
3-
[assembly: NUnit.Framework.LevelOfParallelism(4)]
2+
//[assembly: NUnit.Framework.Parallelizable(NUnit.Framework.ParallelScope.Fixtures)]
3+
//[assembly: NUnit.Framework.LevelOfParallelism(2)]
44

55
// method-level parallel
6-
//[assembly: NUnit.Framework.Parallelizable(NUnit.Framework.ParallelScope.Children)]
7-
//[assembly: NUnit.Framework.LevelOfParallelism(4)]
6+
[assembly: NUnit.Framework.Parallelizable(NUnit.Framework.ParallelScope.Children)]
7+
[assembly: NUnit.Framework.LevelOfParallelism(2)]

ParallelExecution/ReqnrollCalculator.Specs.StepDefinitions/LoggingHooks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ private static void AppendLogMessage(string message, ITestRunner? testRunner = n
1616
var timestamp = Stopwatch.Elapsed;
1717
lock (LockObj)
1818
{
19-
var line = $"{timestamp:c} {testRunner?.TestWorkerId ?? "-"}: {message}";
19+
var line = $"{timestamp:c} {testRunner?.TestWorkerId ?? "-"}/#{Thread.CurrentThread.ManagedThreadId:D2}: {message}";
2020
File.AppendAllLines(LogFileName, newLineAfter ? [line, ""] : [line]);
2121
}
2222
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Feature: Addition4
2+
3+
The calculator functions related to addition,
4+
that is denoted with the '+' operator.
5+
6+
@core
7+
Rule: Positive numbers can be added
8+
9+
Scenario: Add two numbers
10+
This is the most common use-case:
11+
people often sum two numbers.
12+
13+
Given the first number is 50
14+
And the second number is 70
15+
When the two numbers are added
16+
Then the result should be 120
17+
18+
@commutativity
19+
Scenario: Addition is commutative
20+
Given the first number is 70
21+
And the second number is 50
22+
When the two numbers are added
23+
Then the result should be 120
24+
25+
Rule: Non-positive numbers can be added
26+
27+
@edgeCase
28+
Scenario Outline: Add zeros
29+
Given the first number is <first>
30+
And the second number is <second>
31+
When the two numbers are added
32+
Then the result should be <result>
33+
Examples:
34+
| description | first | second | result |
35+
| #1 | 0 | 0 | 0 |
36+
| #2 | 0 | 42 | 42 |
37+
| #3 | 42 | 0 | 42 |
38+
39+
Scenario: Add negatives
40+
Given the entered numbers are
41+
| number |
42+
| -5 |
43+
| -7 |
44+
When the two numbers are added
45+
Then the result should be -12
46+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Xunit;
22

33
// class-level parallel
4-
[assembly: CollectionBehavior(CollectionBehavior.CollectionPerClass, MaxParallelThreads = 4)]
4+
[assembly: CollectionBehavior(CollectionBehavior.CollectionPerClass, MaxParallelThreads = 2)]
55

66
// no parallel
77
//[assembly: CollectionBehavior(CollectionBehavior.CollectionPerClass, DisableTestParallelization = true)]

0 commit comments

Comments
 (0)