Skip to content

Commit

Permalink
Integrate Allure report in all the sample projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Martinez committed May 24, 2024
1 parent d96e2d0 commit 0dbc559
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 33 deletions.
11 changes: 9 additions & 2 deletions samples/TestWare.Samples.API/Hook.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using TestWare.Reporting.ExtentReport;
using TestWare.Reporting.AllureReport;
using TestWare.Reporting.ExtentReport;

namespace TestWare.Samples.API;

Expand All @@ -9,6 +10,7 @@ public sealed class Hook
private int _stepCounter;
private static readonly LifeCycle _lifeCycle = new();
private static ExtentReport _testReport;
private static AllureReport _allureReport;

public Hook(TestContext testContext)
{
Expand Down Expand Up @@ -59,7 +61,11 @@ public void AfterScenario()
public static void BeforeTestRun()
{
_lifeCycle.BeginTestExecution();
_testReport = new ExtentReport(_lifeCycle.GetCurrentResultsDirectory());
_testReport = new ExtentReport(_lifeCycle.GetCurrentResultsDirectory());
var allureConfiguration = _lifeCycle.TestConfiguration.Configurations.First(x => x.Tag == "AllureConfiguration");
_allureReport = new AllureReport(allureConfiguration.Capabilities.FirstOrDefault());
_allureReport.CleanResultsFolder();
_allureReport.GenerateAllureEnvironmentFile();
}

[AfterTestRun]
Expand Down Expand Up @@ -90,6 +96,7 @@ public void AfterStep(ScenarioContext scenarioContext)
foreach (var evidence in evidencesPath)
{
_testReport.AddScreenshotToStep(evidence);
_allureReport.AddAttachment(evidence, Path.GetFileNameWithoutExtension(evidence));
_testContext.AddResultFile(evidence);
}
}
Expand Down
19 changes: 19 additions & 0 deletions samples/TestWare.Samples.API/TestConfiguration.API.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@
"Timeout": 5000
}
]
},
{
"Tag": "AllureConfiguration",
"Capabilities": [
{
"IssueTrackerBaseUrl": "https://www.myissuetracker.com/",
"TestManagementSystemBaseUrl": "https://www.mytms.com/",
"EnvironmentValues": [
{
"key": "System",
"value": "Windows"
},
{
"key": "Type",
"value": "API"
}
]
}
]
}
],
"TestResultPath": "C:\\workspace\\ERNI\\results\\"
Expand Down
4 changes: 4 additions & 0 deletions samples/TestWare.Samples.API/TestWare.Samples.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Core\TestWare.AllureReport\TestWare.AllureReport.csproj" />
<ProjectReference Include="..\..\src\Core\TestWare.Core\TestWare.Core.csproj" />
<ProjectReference Include="..\..\src\Core\TestWare.TestReport\TestWare.ExtentReport.csproj" />
<ProjectReference Include="..\..\src\Engines\TestWare.Engines.API\TestWare.Engines.Restsharp.csproj" />
Expand All @@ -28,6 +29,9 @@
</ItemGroup>

<ItemGroup>
<None Update="specflow.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestConfiguration.API.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
5 changes: 5 additions & 0 deletions samples/TestWare.Samples.API/specflow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"stepAssemblies": [
{ "assembly": "Allure.SpecFlowPlugin" }
]
}
14 changes: 11 additions & 3 deletions samples/TestWare.Samples.Appium.Mobile/Hook.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using TestWare.Reporting.ExtentReport;
using TestWare.Reporting.AllureReport;
using TestWare.Reporting.ExtentReport;

namespace TestWare.Samples.Appium.Mobile;

Expand All @@ -8,7 +9,9 @@ public sealed class Hook
private readonly TestContext _testContext;
private int _stepCounter;
private static readonly LifeCycle _lifeCycle = new();
private static ExtentReport _testReport;
private static ExtentReport _testReport;
private static AllureReport _allureReport;


public Hook(TestContext testContext)
{
Expand Down Expand Up @@ -59,7 +62,11 @@ public void AfterScenario()
public static void BeforeTestRun()
{
_lifeCycle.BeginTestExecution();
_testReport = new ExtentReport(_lifeCycle.GetCurrentResultsDirectory());
_testReport = new ExtentReport(_lifeCycle.GetCurrentResultsDirectory());
var allureConfiguration = _lifeCycle.TestConfiguration.Configurations.First(x => x.Tag == "AllureConfiguration");
_allureReport = new AllureReport(allureConfiguration.Capabilities.FirstOrDefault());
_allureReport.CleanResultsFolder();
_allureReport.GenerateAllureEnvironmentFile();
}

[AfterTestRun]
Expand Down Expand Up @@ -90,6 +97,7 @@ public void AfterStep(ScenarioContext scenarioContext)
foreach (var evidence in evidencesPath)
{
_testReport.AddScreenshotToStep(evidence);
_allureReport.AddAttachment(evidence, Path.GetFileNameWithoutExtension(evidence));
_testContext.AddResultFile(evidence);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,25 @@
]
}
]
},
{
"Tag": "AllureConfiguration",
"Capabilities": [
{
"IssueTrackerBaseUrl": "https://www.myissuetracker.com/",
"TestManagementSystemBaseUrl": "https://www.mytms.com/",
"EnvironmentValues": [
{
"key": "System",
"value": "Windows"
},
{
"key": "Type",
"value": "Mobile"
}
]
}
]
}
],
"TestResultPath": "C:\\workspace\\ERNI\\results\\"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Core\TestWare.AllureReport\TestWare.AllureReport.csproj" />
<ProjectReference Include="..\..\src\Core\TestWare.Core\TestWare.Core.csproj" />
<ProjectReference Include="..\..\src\Core\TestWare.TestReport\TestWare.ExtentReport.csproj" />
<ProjectReference Include="..\..\src\Engines\TestWare.Engines.Appium\TestWare.Engines.Appium.csproj" />
Expand All @@ -32,6 +33,9 @@
<None Update="ExternalResources\SwagLabs.apk">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="specflow.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestConfiguration.Mobile.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
5 changes: 5 additions & 0 deletions samples/TestWare.Samples.Appium.Mobile/specflow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"stepAssemblies": [
{ "assembly": "Allure.SpecFlowPlugin" }
]
}
14 changes: 11 additions & 3 deletions samples/TestWare.Samples.WinAppDriver/Hook.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using TestWare.Reporting.ExtentReport;
using TestWare.Reporting.AllureReport;
using TestWare.Reporting.ExtentReport;

namespace TestWare.Samples.WinAppDriver.Desktop;

Expand All @@ -8,7 +9,9 @@ public sealed class Hook
private readonly TestContext _testContext;
private int _stepCounter;
private static readonly LifeCycle _lifeCycle = new();
private static ExtentReport _testReport;
private static ExtentReport _testReport;
private static AllureReport _allureReport;


public Hook(TestContext testContext)
{
Expand Down Expand Up @@ -59,7 +62,11 @@ public void AfterScenario()
public static void BeforeTestRun()
{
_lifeCycle.BeginTestExecution();
_testReport = new ExtentReport(_lifeCycle.GetCurrentResultsDirectory());
_testReport = new ExtentReport(_lifeCycle.GetCurrentResultsDirectory());
var allureConfiguration = _lifeCycle.TestConfiguration.Configurations.First(x => x.Tag == "AllureConfiguration");
_allureReport = new AllureReport(allureConfiguration.Capabilities.FirstOrDefault());
_allureReport.CleanResultsFolder();
_allureReport.GenerateAllureEnvironmentFile();
}

[AfterTestRun]
Expand Down Expand Up @@ -90,6 +97,7 @@ public void AfterStep(ScenarioContext scenarioContext)
foreach (var evidence in evidencesPath)
{
_testReport.AddScreenshotToStep(evidence);
_allureReport.AddAttachment(evidence, Path.GetFileNameWithoutExtension(evidence));
_testContext.AddResultFile(evidence);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,54 @@
{
"Configurations": [
{
"Tag": "WinAppDriver",
"Capabilities": [
"Configurations": [
{
"Tag": "WinAppDriver",
"Capabilities": [

{
"Name": "Notepad",
"ApplicationPath": "C:\\Windows\\System32\\notepad.exe",
"ApplicationName": "Notepad",
"ApplicationClassName": "Notepad",
"WinAppDriverUrl": "http://127.0.0.1:4723/",
"CommandTimeOutInMinutes": 5
},
{
"Name": "Calculator",
"ApplicationPath": ".\\ExternalResources\\mini-calc.exe",
"ApplicationName": "Mini Calculator Classic",
"ApplicationClassName": "",
"WinAppDriverUrl": "http://127.0.0.1:4723/",
"CommandTimeOutInMinutes": 5
},
{
"Name": "WindowsCalculator",
"ApplicationId": "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App",
"ApplicationName": "Calculator",
"ApplicationClassName": "",
"WinAppDriverUrl": "http://127.0.0.1:4723/",
"CommandTimeOutInMinutes": 5
}
]
},
{
"Tag": "AllureConfiguration",
"Capabilities": [
{
"IssueTrackerBaseUrl": "https://www.myissuetracker.com/",
"TestManagementSystemBaseUrl": "https://www.mytms.com/",
"EnvironmentValues": [
{
"Name": "Notepad",
"ApplicationPath": "C:\\Windows\\System32\\notepad.exe",
"ApplicationName": "Notepad",
"ApplicationClassName": "Notepad",
"WinAppDriverUrl": "http://127.0.0.1:4723/",
"CommandTimeOutInMinutes": 5
},
{
"Name": "Calculator",
"ApplicationPath": ".\\ExternalResources\\mini-calc.exe",
"ApplicationName": "Mini Calculator Classic",
"ApplicationClassName": "",
"WinAppDriverUrl": "http://127.0.0.1:4723/",
"CommandTimeOutInMinutes": 5
"key": "System",
"value": "Windows"
},
{
"Name": "WindowsCalculator",
"ApplicationId": "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App",
"ApplicationName": "Calculator",
"ApplicationClassName": "",
"WinAppDriverUrl": "http://127.0.0.1:4723/",
"CommandTimeOutInMinutes": 5
"key": "Type",
"value": "Desktop"
}
]
}
}
]
}
],
"TestResultPath": "C:\\workspace\\ERNI\\results\\"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Core\TestWare.AllureReport\TestWare.AllureReport.csproj" />
<ProjectReference Include="..\..\src\Core\TestWare.Core\TestWare.Core.csproj" />
<ProjectReference Include="..\..\src\Core\TestWare.TestReport\TestWare.ExtentReport.csproj" />
<ProjectReference Include="..\..\src\Engines\TestWare.Engines.Appium\TestWare.Engines.Appium.csproj" />
Expand All @@ -26,6 +27,9 @@
<None Update="ExternalResources\mini-calc.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="specflow.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestConfiguration.Desktop.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
5 changes: 5 additions & 0 deletions samples/TestWare.Samples.WinAppDriver/specflow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"stepAssemblies": [
{ "assembly": "Allure.SpecFlowPlugin" }
]
}

0 comments on commit 0dbc559

Please sign in to comment.