Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/allure report #86

Merged
merged 4 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/Allure_Report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: allure-report
on:
workflow_call:
inputs:
artifact_name:
required: true
type: string
workflow:
required: true
type: string


jobs:
allure:
name: Generate Allure Report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Get Allure history
uses: actions/checkout@v2
if: always()
continue-on-error: true
with:
ref: gh-pages
path: gh-pages

- uses: LexisNexis-Public-GHA/sbs-action-download-artifact@v2.13.1
with:
workflow: |
${{ inputs.workflow }}
name: |
${{ inputs.artifact_name }}

- name: Allure Report action from marketplace
uses: simple-elf/allure-report-action@master
if: always()
with:
allure_results: allure-results
allure_history: allure-history
keep_reports: 20

- name: Deploy report to Github Pages
if: always()
uses: peaceiris/actions-gh-pages@v2
env:
PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: allure-history
179 changes: 95 additions & 84 deletions .github/workflows/Run_web_tests.yml
Original file line number Diff line number Diff line change
@@ -1,84 +1,95 @@
name: Run-web-tests

on:
workflow_call:
inputs:
driver_type:
required: true
type: string
test_results_path:
required: true
type: string
environment:
required: true
type: string
jobs:
web-tests:
strategy:
matrix:
os: ${{fromJson(inputs.environment)}}
browser: ${{fromJson(inputs.driver_type)}}
fail-fast: false

name: Run WEB (${{ matrix.browser }}) tests - ${{ matrix.os }}
runs-on: ${{ matrix.os }}

steps:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- uses: LexisNexis-Public-GHA/sbs-action-download-artifact@v2.13.1
with:
workflow: CI.yml
name: testing-artifact-selenium-web
- name: Run git init
run: git init
- name: Get Driver path by browser
run: |
switch ( "${{ matrix.browser }}".ToLower() )
{
"chrome" { $driverPathRaw = "$env:CHROMEWEBDRIVER" }
"firefox" { $driverPathRaw = "$env:GeckoWebDriver" }
"edge" { $driverPathRaw = "$env:EdgeWebDriver" }
"internetexplorer" { $driverPathRaw = "$env:IEWebDriver" }
}
echo "driverPathRaw=$driverPathRaw" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf-8 -Append
shell: pwsh
- name: config replacement
uses: microsoft/variable-substitution@v1
with:
files: '.\TestConfiguration.Web.json'
env:
Configurations.0.Capabilities.0.Path: ${{ env.driverPathRaw }}
Configurations.0.Capabilities.0.Driver: ${{ matrix.browser }}
Configurations.1.Capabilities.0.Driver: ${{ matrix.browser }}
Configurations.1.Capabilities.0.Path: ${{ env.driverPathRaw }}
Configurations.1.Capabilities.1.Driver: ${{ matrix.browser }}
Configurations.1.Capabilities.1.Path: ${{ env.driverPathRaw }}
Configurations.1.Capabilities.2.Driver: ${{ matrix.browser }}
Configurations.1.Capabilities.2.Path: ${{ env.driverPathRaw }}
TestResultPath: ${{ inputs.test_results_path }}
- name: Read configuration
id: config_file
uses: juliangruber/read-file-action@v1
with:
path: '.\TestConfiguration.Web.json'
- name: Echo configuration.json
run: echo "${{ steps.config_file.outputs.content }}"
- name: Run tests
run: dotnet test TestWare.Samples.Selenium.Web.dll --logger "trx;LogFileName=results.trx" --results-directory "${{ inputs.test_results_path }}"
- name: Archive WEB (${{ matrix.browser }}) screenshots
if: always()
uses: actions/upload-artifact@v2
with:
name: web-${{ matrix.browser }}-screenshots
path: |
${{ inputs.test_results_path }}
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Report - WEB (${{ matrix.browser }} - ${{ matrix.os }})
path: ${{ inputs.test_results_path }}/results.trx
reporter: dotnet-trx
name: Run-web-tests

on:
workflow_call:
inputs:
driver_type:
required: true
type: string
test_results_path:
required: true
type: string
environment:
required: true
type: string
jobs:
web-tests:
strategy:
matrix:
os: ${{fromJson(inputs.environment)}}
browser: ${{fromJson(inputs.driver_type)}}
fail-fast: false

name: Run WEB (${{ matrix.browser }}) tests - ${{ matrix.os }}
runs-on: ${{ matrix.os }}

steps:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- uses: LexisNexis-Public-GHA/sbs-action-download-artifact@v2.13.1
with:
workflow: CI.yml
name: testing-artifact-selenium-web
- name: Run git init
run: git init
- name: Get Driver path by browser
run: |
switch ( "${{ matrix.browser }}".ToLower() )
{
"chrome" { $driverPathRaw = "$env:CHROMEWEBDRIVER" }
"firefox" { $driverPathRaw = "$env:GeckoWebDriver" }
"edge" { $driverPathRaw = "$env:EdgeWebDriver" }
"internetexplorer" { $driverPathRaw = "$env:IEWebDriver" }
}
echo "driverPathRaw=$driverPathRaw" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf-8 -Append
shell: pwsh
- name: config replacement
uses: microsoft/variable-substitution@v1
with:
files: '.\TestConfiguration.Web.json'
env:
Configurations.0.Capabilities.0.Path: ${{ env.driverPathRaw }}
Configurations.0.Capabilities.0.Driver: ${{ matrix.browser }}
Configurations.1.Capabilities.0.Driver: ${{ matrix.browser }}
Configurations.1.Capabilities.0.Path: ${{ env.driverPathRaw }}
Configurations.1.Capabilities.1.Driver: ${{ matrix.browser }}
Configurations.1.Capabilities.1.Path: ${{ env.driverPathRaw }}
Configurations.1.Capabilities.2.Driver: ${{ matrix.browser }}
Configurations.1.Capabilities.2.Path: ${{ env.driverPathRaw }}
TestResultPath: ${{ inputs.test_results_path }}
- name: Read configuration
id: config_file
uses: juliangruber/read-file-action@v1
with:
path: '.\TestConfiguration.Web.json'
- name: Echo configuration.json
run: echo "${{ steps.config_file.outputs.content }}"
- name: Run tests
run: dotnet test TestWare.Samples.Selenium.Web.dll --logger "trx;LogFileName=results.trx" --results-directory "${{ inputs.test_results_path }}"
- name: Archive WEB (${{ matrix.browser }}) screenshots
if: always()
uses: actions/upload-artifact@v2
with:
name: web-${{ matrix.browser }}-screenshots
path: |
${{ inputs.test_results_path }}
- name: Archive Testing artifacts - Allure
uses: actions/upload-artifact@v2
with:
name: allure-results-web
path: '.\allure-results'
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Report - WEB (${{ matrix.browser }} - ${{ matrix.os }})
path: ${{ inputs.test_results_path }}/results.trx
reporter: dotnet-trx

allure-results:
uses: ./.github/workflows/Allure_Report.yml
with:
artifact_name: 'allure-results-web'
workflow: 'Run_web_tests.yml'
7 changes: 7 additions & 0 deletions TestWare.sln
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestWare.ExtentReport", "sr
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Reporting", "Reporting", "{DCCEF363-0EBE-46EA-B02B-CD59010626F6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestWare.AllureReport", "src\Core\TestWare.AllureReport\TestWare.AllureReport.csproj", "{91F2B723-A68B-4711-969B-89897B3C6161}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -84,6 +86,10 @@ Global
{94025C6B-DF0D-4AC4-BBC5-A94A9FA3AB0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94025C6B-DF0D-4AC4-BBC5-A94A9FA3AB0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94025C6B-DF0D-4AC4-BBC5-A94A9FA3AB0A}.Release|Any CPU.Build.0 = Release|Any CPU
{91F2B723-A68B-4711-969B-89897B3C6161}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91F2B723-A68B-4711-969B-89897B3C6161}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91F2B723-A68B-4711-969B-89897B3C6161}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91F2B723-A68B-4711-969B-89897B3C6161}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -102,6 +108,7 @@ Global
{71120454-DD7A-484C-93F2-699B4C363297} = {58B1446D-98A3-46A2-A668-305F0170B39F}
{94025C6B-DF0D-4AC4-BBC5-A94A9FA3AB0A} = {DCCEF363-0EBE-46EA-B02B-CD59010626F6}
{DCCEF363-0EBE-46EA-B02B-CD59010626F6} = {4678C707-68DB-4E06-9184-A07FB398832C}
{91F2B723-A68B-4711-969B-89897B3C6161} = {DCCEF363-0EBE-46EA-B02B-CD59010626F6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4F88CB24-23C8-4E0E-8B83-29023C1642B8}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@WebDriver
Feature: Login

@critical
Scenario Outline: Login
Given the user enters username '<username>'
And the user enters password '<password>'
Expand All @@ -12,6 +13,9 @@ Scenario Outline: Login
| standard | standard_user | secret_sauce |
| problem | problem_user | secret_sauce |

@blocker
@tms:5
@issue:3
Scenario: Logout
Given user 'standard_user' is logged with 'secret_sauce' into SwagLabs
When the user clicks Logout button
Expand Down
24 changes: 16 additions & 8 deletions samples/TestWare.Samples.Selenium.Web/Hook.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Globalization;
using TestWare.Reporting.ExtentReport;
using TestWare.Reporting.AllureReport;

namespace TestWare.Samples.Selenium.Web;

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

public Hook(TestContext testContext)
{
Expand All @@ -23,7 +25,7 @@ public static void BeforeFeature(FeatureContext featureContext)
var tags = featureContext.FeatureInfo.Tags;

_lifeCycle.BeginTestSuite(name);
_testReport.CreateFeature(name, tags);
_extentReport.CreateFeature(name, tags);
}

[AfterFeature]
Expand All @@ -41,7 +43,7 @@ public void BeforeScenario(FeatureContext featureContext, ScenarioContext scenar

var description = scenarioContext.ScenarioInfo.Description ?? "";
var scenarioTags = scenarioContext.ScenarioInfo.Tags;
_testReport.CreateTestCase(name, description, scenarioTags);
_extentReport.CreateTestCase(name, description, scenarioTags);

_testContext.WriteLine("----------------------------------------- \r\n");
_testContext.WriteLine($"Feature: {featureContext.FeatureInfo.Title}");
Expand All @@ -55,30 +57,35 @@ public void BeforeScenario(FeatureContext featureContext, ScenarioContext scenar
[AfterScenario]
public void AfterScenario()
{
_testReport.SetTestcaseOutcome(_testContext.CurrentTestOutcome);
_extentReport.SetTestcaseOutcome(_testContext.CurrentTestOutcome);
_lifeCycle.EndTestCase();
}

[BeforeTestRun]
public static void BeforeTestRun()
{
_lifeCycle.BeginTestExecution();
_testReport = new ExtentReport(_lifeCycle.GetCurrentResultsDirectory());
_extentReport = 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]
public static void AfterTestRun()
{
_lifeCycle.EndTestExecution();
_testReport.CreateTestReportFile();
_extentReport.CreateTestReportFile();
}

[BeforeStep]
public void BeforeStep(ScenarioContext scenarioContext)
{
var name = scenarioContext.CurrentScenarioBlock.ToString();
var description = scenarioContext.StepContext.StepInfo.Text;
_testReport.CreateStep(name, description);
_extentReport.CreateStep(name, description);

var stepId = $"{_stepCounter:00} {description}";
_stepCounter++;
Expand All @@ -93,7 +100,8 @@ public void AfterStep(ScenarioContext scenarioContext)

foreach (var evidence in evidencesPath)
{
_testReport.AddScreenshotToStep(evidence);
_extentReport.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 @@ -83,6 +83,27 @@
]
}
]
},
{
"Tag": "AllureConfiguration",
"Capabilities": [
{
"IssueTrackerBaseUrl": "https://www.myissuetracker.com/",
"IssueTagRegex": "^issue:(\\d+)",
"TestManagementSystemBaseUrl": "https://www.mytms.com/",
"TestManagementSystemTagRegex": "^tms:(\\d+)",
"EnvironmentValues": [
{
"key": "System",
"value": "Windows"
},
{
"key": "WebDriver",
"value": "Chrome"
}
]
}
]
}
],
"TestResultPath": "C:\\workspace\\ERNI\\results\\"
Expand Down
Loading
Loading