-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
537c4b6
commit 4c2f216
Showing
3 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using Gauge.Messages; | ||
using ReportPortal.Client.Abstractions.Models; | ||
using ReportPortal.Client.Abstractions.Requests; | ||
using ReportPortal.Shared.Reporter; | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace ReportPortal.GaugePlugin.Results | ||
{ | ||
partial class Sender | ||
{ | ||
/// <summary> | ||
/// Assuming scenario might have only on running concept. | ||
/// </summary> | ||
private readonly ConcurrentDictionary<ScenarioKey, List<ITestReporter>> _scenarioConcepts = new(); | ||
|
||
public void StartConcept(ConceptExecutionStartingRequest request) | ||
{ | ||
var scenarioKey = GetScenarioKey(request.CurrentExecutionInfo, request.CurrentExecutionInfo.CurrentSpec, request.CurrentExecutionInfo.CurrentScenario); | ||
|
||
var parentReporter = _scenarioConcepts.ContainsKey(scenarioKey) ? _scenarioConcepts[scenarioKey].Last() : _scenarios[scenarioKey]; | ||
|
||
var conceptReporter = parentReporter.StartChildTestReporter(new StartTestItemRequest | ||
{ | ||
Name = request.CurrentExecutionInfo.CurrentStep.Step.ParsedStepText, | ||
StartTime = DateTime.UtcNow, | ||
HasStats = false | ||
}); | ||
|
||
if (_scenarioConcepts.TryGetValue(scenarioKey, out List<ITestReporter> concepts)) | ||
{ | ||
concepts.Add(conceptReporter); | ||
} | ||
else | ||
{ | ||
_scenarioConcepts[scenarioKey] = [conceptReporter]; | ||
} | ||
} | ||
|
||
public void FinishConcept(ConceptExecutionEndingRequest request) | ||
{ | ||
var scenarioKey = GetScenarioKey(request.CurrentExecutionInfo, request.CurrentExecutionInfo.CurrentSpec, request.CurrentExecutionInfo.CurrentScenario); | ||
|
||
var conceptReporter = _scenarioConcepts[scenarioKey].Last(); | ||
|
||
var status = request.CurrentExecutionInfo.CurrentScenario.IsFailed ? Status.Failed : Status.Passed; | ||
|
||
conceptReporter.Finish(new FinishTestItemRequest | ||
{ | ||
Status = status, | ||
EndTime = DateTime.UtcNow | ||
}); | ||
|
||
var concepts = _scenarioConcepts[scenarioKey]; | ||
|
||
if (concepts.Count == 1) | ||
{ | ||
_scenarioConcepts.Remove(scenarioKey, out _); | ||
} | ||
else | ||
{ | ||
concepts.Remove(conceptReporter); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters