Skip to content

Commit

Permalink
Merge pull request #4 from aquality-automation/Enhancement/make-scree…
Browse files Browse the repository at this point in the history
…n-eachtime-after

to quick demo of screenshot attachments made changes to make screenshots each time after test (not only for failed)
  • Loading branch information
aqualityAutomation authored Feb 28, 2024
2 parents 96db0e2 + fe22040 commit 0a61218
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aquality.WinAppDriver" Version="0.5.2" />
<PackageReference Include="Allure.SpecFlow" Version="2.11.0" />
<PackageReference Include="Aquality.WinAppDriver" Version="2.0.0" />
<PackageReference Include="AqualityTracking.SpecFlowPlugin" Version="1.0.1" />
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1">
<PackageReference Include="nunit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="SpecFlow" Version="3.1.97" />
<PackageReference Include="SpecFlow.Allure" Version="3.0.0.10" />
<PackageReference Include="SpecFlow.NUnit" Version="3.1.97" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.1.97" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="SpecFlow" Version="3.9.74" />
<PackageReference Include="SpecFlow.NUnit" Version="3.9.74" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.74" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Allure.Commons;
using Allure.Net.Commons;
using AqualityTracking.Integrations.Core;
using NUnit.Framework;
using System.Text.RegularExpressions;
Expand All @@ -19,8 +19,7 @@ public PluginsHooks(ScenarioContext context)
[AfterScenario(Order = -1)]
public void UpdateAllureTestCaseName()
{
context.TryGetValue(out TestResult testresult);
AllureLifecycle.Instance.UpdateTestCase(testresult.uuid, testCase =>
AllureLifecycle.Instance.UpdateTestCase(testCase =>
{
testCase.name += GetScenarioNameSuffix();
testCase.historyId = TestContext.CurrentContext.Test.FullName;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Allure.Commons;
using Allure.Net.Commons;
using Aquality.WinAppDriver.Applications;
using Aquality.WinAppDriver.Template.Utilities;
using AqualityTracking.Integrations.Core;
Expand All @@ -8,26 +8,18 @@
namespace Aquality.WinAppDriver.Template.SpecFlow.Hooks
{
[Binding]
public class ScreenshotHooks
public class ScreenshotHooks(ScreenshotProvider screenshotProvider)
{
private readonly ScreenshotProvider screenshotProvider;
private readonly ScenarioContext scenarioContext;

public ScreenshotHooks(ScenarioContext scenarioContext, ScreenshotProvider screenshotProvider)
{
this.scenarioContext = scenarioContext;
this.screenshotProvider = screenshotProvider;
}
private readonly ScreenshotProvider screenshotProvider = screenshotProvider;

[AfterScenario(Order = 0)]
public void TakeScreenshot()
{
if (scenarioContext.ScenarioExecutionStatus != ScenarioExecutionStatus.OK
&& AqualityServices.IsApplicationStarted)
if (AqualityServices.IsApplicationStarted)
{
var pathToScreenshot = screenshotProvider.TakeScreenshot();
TestContext.AddTestAttachment(pathToScreenshot);
AllureLifecycle.Instance.AddAttachment(pathToScreenshot, "Screenshot");
AllureApi.AddAttachment(pathToScreenshot, "Screenshot");
AqualityTrackingLifecycle.Instance.AddAttachment(pathToScreenshot);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"enabled": false,
"host": "{aquality_tracking_address}",
"token": "{api_token}",
"projectId": 0,
"host": "{protocol_host_and_port}",
"token": "{generated_api_token}",
"projectId": 1,
"executor": "{name_of_executor}",
"suiteName": "{name_of_test_suite}",
"suiteName": "{project_suite_name_to_import}",
"buildName": "{name_of_ci_build}",
"environment": "{name_of_execution_environment}",
"ciBuild": "{link_to_ci_build}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Aquality.WinAppDriver" Version="0.5.2" />
<PackageReference Include="Aquality.WinAppDriver" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,11 @@
},
"elementCache": {
"isEnabled": true
},
"visualization": {
"defaultThreshold": 0.03,
"comparisonWidth": 16,
"comparisonHeight": 16,
"pathToDumps": "../../../Resources/VisualDumps/"
}
}

0 comments on commit 0a61218

Please sign in to comment.