-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement an adapter for Reqnroll (#453) * Port samples from Allure.Features to Reqnroll * Write configuration tests for Allure Reqnroll * Port integration tests of allure-specflow to Reqnroll * Remove stepAssemblies from README and samples * Test Allure Reqnroll in build workflow * Add Allure.Reqnroll entries to README and labeler * Port test configuration fix from SpecFlow * Remove IgnoreException from reqnroll samples * Describe where to find results by default for Reqnroll * Remove file with unused NUnit attrs
- Loading branch information
Showing
48 changed files
with
3,258 additions
and
2 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
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
33 changes: 33 additions & 0 deletions
33
Allure.Reqnroll.Tests.Samples/Allure.Reqnroll.Tests.Samples.csproj
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,33 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<RootNamespace>Allure.ReqnrollPlugin.Tests.Samples</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="allureConfig.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" /> | ||
<PackageReference Include="Castle.Core" Version="5.1.1" /> | ||
<PackageReference Include="Reqnroll" Version="1.0.1" /> | ||
<PackageReference Include="Reqnroll.Tools.MsBuild.Generation" Version="1.0.1" /> | ||
<PackageReference Include="Reqnroll.xUnit" Version="1.0.1" /> | ||
<PackageReference Include="xunit" Version="2.7.0" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Allure.Net.Commons\Allure.Net.Commons.csproj" /> | ||
<ProjectReference Include="..\Allure.Reqnroll\Allure.Reqnroll.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,114 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Allure.Net.Commons; | ||
using Reqnroll; | ||
using Reqnroll.UnitTestProvider; | ||
using Xunit; | ||
|
||
namespace Allure.ReqnrollPlugin.Tests.Samples; | ||
public enum TestOutcome | ||
{ | ||
passed, | ||
failed, | ||
broken | ||
} | ||
|
||
[Binding] | ||
public class BindingDefinitions | ||
{ | ||
readonly ScenarioContext scenarioContext; | ||
readonly IUnitTestRuntimeProvider runnerRuntimeApi; | ||
|
||
public BindingDefinitions(ScenarioContext scenarioContext, IUnitTestRuntimeProvider runnerRuntimeApi) | ||
{ | ||
this.scenarioContext = scenarioContext; | ||
this.runnerRuntimeApi = runnerRuntimeApi; | ||
} | ||
|
||
[BeforeTestRun] | ||
public static void BeforeTestRun() => | ||
AllureLifecycle.Instance.CleanupResultDirectory(); | ||
|
||
[StepDefinition(@"Step is '(.*)'")] | ||
public static async Task StepResultIs(TestOutcome outcome) | ||
{ | ||
switch (outcome) | ||
{ | ||
case TestOutcome.failed: | ||
Assert.Fail("Assertion failed"); | ||
break; | ||
case TestOutcome.broken: | ||
throw new Exception("This test was failed"); | ||
} | ||
await Task.CompletedTask; | ||
} | ||
|
||
[StepDefinition("Step with attachment")] | ||
public static void StepWithAttach() => | ||
AllureApi.AddAttachment( | ||
"Text attachment", | ||
"text/plain", | ||
"Attachment content"u8.ToArray() | ||
); | ||
|
||
[StepDefinition("Step with table")] | ||
public static void StepWithTable(Table _) { } | ||
|
||
[StepDefinition("Step with params: (.*)")] | ||
public static void StepWithArgs(int _, string __) { } | ||
|
||
[BeforeFeature("beforefeaturepassed", Order = 1)] | ||
public static void PassedBeforeFeature() { } | ||
|
||
[AfterFeature("afterfeaturepassed", Order = 1)] | ||
public static void PassedAfterFeature() { } | ||
|
||
[BeforeFeature("beforefeaturefailed")] | ||
public static void FailedBeforeFeature() => | ||
throw new Exception("BeforeFeature failed"); | ||
|
||
[AfterFeature("afterfeaturefailed")] | ||
public static void FailedAfterFeature() => | ||
throw new Exception("AfterFeature failed"); | ||
|
||
[BeforeScenario("beforescenario")] | ||
[AfterScenario("afterscenario")] | ||
[BeforeStep("beforestep")] | ||
[AfterStep("afterstep")] | ||
public void HandleIt() => | ||
this.Handle(scenarioContext.ScenarioInfo.Tags); | ||
|
||
void Handle(string[] tags) | ||
{ | ||
if (tags != null && tags.Contains("attachment")) | ||
{ | ||
var content = "text file"u8.ToArray(); | ||
AllureApi.AddAttachment("attachment-1", "text/plain", content, ".txt"); | ||
AllureApi.AddAttachment("attachment-2", "text/plain", content, ".txt"); | ||
} | ||
|
||
if (tags != null) | ||
{ | ||
if (ShouldFail(tags)) | ||
{ | ||
Assert.Fail("The hook has failed"); | ||
} | ||
else if (ShouldBreak(tags)) | ||
{ | ||
throw new Exception("The hook is broken"); | ||
} | ||
else if (tags.Contains("runtimeignore")) | ||
{ | ||
this.runnerRuntimeApi.TestIgnore("Ignored because of '@runtimeignore'"); | ||
} | ||
} | ||
} | ||
|
||
static bool ShouldFail(IEnumerable<string> tags) => | ||
tags.Any(t => t.EndsWith("failed")); | ||
|
||
static bool ShouldBreak(IEnumerable<string> tags) => | ||
tags.Any(t => t.EndsWith("broken")); | ||
} |
10 changes: 10 additions & 0 deletions
10
Allure.Reqnroll.Tests.Samples/Features/After Feature Failure.feature
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,10 @@ | ||
@afterfeaturefailed | ||
Feature: After Feature Failure | ||
|
||
@passed | ||
Scenario: After Feature Failure 1 | ||
Given Step is 'passed' | ||
|
||
@failed | ||
Scenario: After Feature Failure 3 | ||
Given Step is 'failed' |
26 changes: 26 additions & 0 deletions
26
Allure.Reqnroll.Tests.Samples/Features/Attachments.feature
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,26 @@ | ||
Feature: Attachments | ||
|
||
@passed @attachment @beforescenario @afterscenario | ||
Scenario: With attachments | ||
Given Step with attachment | ||
Given Step is 'passed' | ||
|
||
@broken @attachment @beforescenario | ||
Scenario: Failed BeforeScenario with attachment | ||
Given Step with attachment | ||
Given Step is 'passed' | ||
|
||
@broken @attachment @afterscenario | ||
Scenario: Failed AfterScenario with attachment | ||
Given Step with attachment | ||
Given Step is 'passed' | ||
|
||
@broken @attachment @beforestep | ||
Scenario: Failed BeforeStep with attachment | ||
Given Step with attachment | ||
Given Step is 'passed' | ||
|
||
@broken @attachment @afterstep | ||
Scenario: Failed AfterStep with attachment | ||
Given Step with attachment | ||
Given Step is 'passed' |
5 changes: 5 additions & 0 deletions
5
Allure.Reqnroll.Tests.Samples/Features/Before Feature Failure.feature
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,5 @@ | ||
@beforefeaturefailed | ||
Feature: Before Feature Failure | ||
|
||
@broken | ||
Scenario: BeforeFeature of 'Before Feature Failure' has failed |
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,6 @@ | ||
Feature: Ignored | ||
Treat exceptions thrown by IUnitTestRuntimeProvider.TestIgnore as skipped | ||
(works in NUnit and xUnit.net) | ||
|
||
@beforescenario @runtimeignore @skipped | ||
Scenario: Should be ignored at runtime |
20 changes: 20 additions & 0 deletions
20
Allure.Reqnroll.Tests.Samples/Features/Invalid Steps.feature
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,20 @@ | ||
Feature: Invalid Steps | ||
|
||
@broken | ||
Scenario: All steps are invalid | ||
Given I don't have such step | ||
And I don't have such step too | ||
|
||
@broken | ||
Scenario: Some steps are invalid | ||
Given Step is 'passed' | ||
Given I don't have such step | ||
Given Step is 'passed' | ||
And I don't have such step too | ||
|
||
@failed | ||
Scenario: Failed step followed by invalid step | ||
Given Step is 'failed' | ||
Given I don't have such step | ||
Given Step is 'passed' | ||
And I don't have such step too |
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,23 @@ | ||
@labels @core @epic:v1.2 @owner:JohnDoe | ||
Feature: Labels | ||
|
||
@passed @ui @story:accounting @123 @tms:234 @tag1 | ||
Scenario: [v1.2 accounting] [ui.core] Selenium test 1 | ||
|
||
@passed @api @blocker @567 @999999 | ||
Scenario: [v1.2] [api.core] Api test 1 | ||
|
||
@passed @api @create @link:http://example.org | ||
Scenario: [v1.2] [api.core.create] Api test 2 | ||
|
||
@passed @api @update | ||
Scenario: [v1.2] [api.core.update] Api test 3 | ||
|
||
@passed @update @story:accounting | ||
Scenario: [v1.2 accounting] [core.update] Update test | ||
|
||
@passed @epic:v.2.0 @story:security | ||
Scenario: [v1.2 / v.2.0 security] [core.update] [com.company.security.main.getACL] Get ACL test | ||
|
||
@passed @label:layer:e2e @label:allure_id:9894 @label:custom_label:pepa | ||
Scenario: Layer e2e (label) |
27 changes: 27 additions & 0 deletions
27
Allure.Reqnroll.Tests.Samples/Features/Scenario Hooks.feature
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,27 @@ | ||
Feature: Scenario and Step Bindings | ||
|
||
@broken @beforescenario @beforestep | ||
Scenario: Should handle BeforeScenario and BeforeStep failure | ||
Given Step is 'passed' | ||
Given Step is 'passed' | ||
|
||
@broken @beforescenario | ||
Scenario: Should handle BeforeScenario failure | ||
Given Step is 'passed' | ||
Given Step is 'passed' | ||
|
||
@broken @beforestep | ||
Scenario: Should handle BeforeStep failure | ||
Given Step is 'passed' | ||
Given Step is 'passed' | ||
Given Step is 'passed' | ||
|
||
@broken @afterstep | ||
Scenario: Should handle AfterStep failure | ||
Given Step is 'passed' | ||
Given Step is 'passed' | ||
|
||
@broken @afterscenario | ||
Scenario: Should handle AfterScenario failure | ||
Given Step is 'passed' | ||
Given Step is 'passed' |
25 changes: 25 additions & 0 deletions
25
Allure.Reqnroll.Tests.Samples/Features/Scenarios and Steps.feature
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,25 @@ | ||
Feature: Scenarios and Steps | ||
|
||
@passed | ||
Scenario: Empty scenario | ||
|
||
@passed | ||
Scenario: Passed scenario | ||
Given Step is 'passed' | ||
|
||
@failed | ||
Scenario: Failed scenario | ||
Given Step is 'passed' | ||
Given Step is 'failed' | ||
Given Step is 'passed' | ||
|
||
@passed @examples | ||
Scenario Outline: Scenario with examples | ||
Given Step with table | ||
| id | <id> | | ||
| name | <name> | | ||
|
||
Examples: | ||
| id | name | | ||
| 1 | John | | ||
| 2 | Alex | |
Oops, something went wrong.