|
1 |
| -using System.Collections; |
2 |
| -using System.Diagnostics; |
3 |
| -using System.Reflection; |
4 | 1 | using Reqnroll;
|
5 | 2 |
|
6 | 3 | namespace ReqnrollCalculator.Specs.StepDefinitions;
|
7 | 4 |
|
8 | 5 | [Binding]
|
9 | 6 | public sealed class CalculatorStepDefinitions
|
10 | 7 | {
|
11 |
| - private static readonly Stopwatch Stopwatch = new(); |
12 |
| - private static readonly object LockObj = new(); |
13 | 8 | private static readonly Random Rnd = new(42);
|
14 |
| - private static readonly string LogFileName = $"parallel_log_{typeof(CalculatorStepDefinitions).Assembly.GetName().Name}.txt"; |
15 |
| - |
16 |
| - private static void AppendLogMessage(string message, ITestRunner? testRunner = null, bool newLineAfter = false) |
17 |
| - { |
18 |
| - var timestamp = Stopwatch.Elapsed; |
19 |
| - lock (LockObj) |
20 |
| - { |
21 |
| - var line = $"{timestamp:c} {testRunner?.TestWorkerId ?? "-"}: {message}"; |
22 |
| - File.AppendAllLines(LogFileName, newLineAfter ? [line, ""] : [line]); |
23 |
| - } |
24 |
| - } |
25 | 9 |
|
26 | 10 | private const bool AddRandomWait = true;
|
27 |
| - private const int MinWaitMs = 100; |
28 |
| - private const int MaxWaitMs = 150; |
| 11 | + private const int MinWaitMs = 300; |
| 12 | + private const int MaxWaitMs = 350; |
29 | 13 |
|
30 | 14 | private readonly Calculator _calculator = new();
|
31 | 15 |
|
32 |
| - [BeforeTestRun] |
33 |
| - public static void RunStart() |
34 |
| - { |
35 |
| - Stopwatch.Start(); |
36 |
| - AppendLogMessage("BeforeTestRun"); |
37 |
| - } |
38 |
| - |
39 |
| - [AfterTestRun] |
40 |
| - public static void RunEnd() |
41 |
| - { |
42 |
| - AppendLogMessage("AfterTestRun", newLineAfter: true); |
43 |
| - } |
44 |
| - |
45 |
| - [BeforeFeature] |
46 |
| - public static void FeatureStart(FeatureContext featureContext, ITestRunner testRunner) |
47 |
| - { |
48 |
| - AppendLogMessage($" BeforeFeature: {featureContext.FeatureInfo.Title}", testRunner); |
49 |
| - } |
50 |
| - |
51 |
| - [AfterFeature] |
52 |
| - public static void FeatureEnd(FeatureContext featureContext, ITestRunner testRunner) |
53 |
| - { |
54 |
| - AppendLogMessage($" AfterFeature: {featureContext.FeatureInfo.Title}", testRunner); |
55 |
| - } |
56 |
| - |
57 |
| - private string GetScenarioTitle(ScenarioContext scenarioContext) |
58 |
| - { |
59 |
| - if (scenarioContext.ScenarioInfo.Arguments == null || scenarioContext.ScenarioInfo.Arguments.Count == 0) |
60 |
| - return scenarioContext.ScenarioInfo.Title; |
61 |
| - |
62 |
| - return $"{scenarioContext.ScenarioInfo.Title} / {string.Join(",", scenarioContext.ScenarioInfo.Arguments.OfType<DictionaryEntry>().Select(a => a.Value))}"; |
63 |
| - } |
64 |
| - |
65 |
| - [BeforeScenario] |
66 |
| - public void ScenarioStart(FeatureContext featureContext, ScenarioContext scenarioContext, ITestRunner testRunner) |
67 |
| - { |
68 |
| - AppendLogMessage($" BeforeScenario: {featureContext.FeatureInfo.Title} / {GetScenarioTitle(scenarioContext)}", testRunner); |
69 |
| - } |
70 |
| - |
71 |
| - [AfterScenario] |
72 |
| - public void ScenarioEnd(FeatureContext featureContext, ScenarioContext scenarioContext, ITestRunner testRunner) |
73 |
| - { |
74 |
| - AppendLogMessage($" AfterScenario: {featureContext.FeatureInfo.Title} / {GetScenarioTitle(scenarioContext)}", testRunner); |
75 |
| - } |
76 |
| - |
77 | 16 | [Given("the first number is {int}")]
|
78 | 17 | public void GivenTheFirstNumberIs(int number)
|
79 | 18 | {
|
|
0 commit comments