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

Add Allure.NUnit package. Big thanks to @unickq for great work on it! #280

Merged
merged 6 commits into from
Jul 27, 2022
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
46 changes: 33 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,76 @@ on:
nextVersion:
description: "The next version in <MAJOR>.<MINOR> format WITHOUT SNAPSHOT SUFFIX"
required: true
prerelease:
description: "Preview release"
required: true
type: boolean
default: false
previewVersion:
description: "Preview version number, integer"
required: false
default: "1"

jobs:
triage:
runs-on: ubuntu-latest
steps:
- name: "Check release version"
run: |
expr "${{ github.event.inputs.releaseVersion }}" : '[[:digit:]][[:digit:]]*\.[[:digit:]][[:digit:]]*\.[[:digit:]][[:digit:]]*$'
expr "${{ inputs.releaseVersion }}" : '[[:digit:]][[:digit:]]*\.[[:digit:]][[:digit:]]*\.[[:digit:]][[:digit:]]*$'
echo "release_version=${{ inputs.releaseVersion }}" >> $GITHUB_ENV
- name: "Check next version"
run: |
expr "${{ github.event.inputs.nextVersion }}" : '[[:digit:]][[:digit:]]*\.[[:digit:]][[:digit:]]*$'
expr "${{ inputs.nextVersion }}" : '[[:digit:]][[:digit:]]*\.[[:digit:]][[:digit:]]*$'
- uses: actions/checkout@v3.0.2
with:
token: ${{ secrets.QAMETA_CI }}

- name: "Mark release as preview"
if: ${{ inputs.prerelease }}
run: |
echo "release_version=${{ inputs.releaseVersion }}-preview.{{ $inputs.previewVersion }}" >> $GITHUB_ENV

- name: "Configure CI Git User"
run: |
git config --global user.name qameta-ci
git config --global user.email qameta-ci@qameta.io
- name: "Set release version"
run: |
sed -i -e '/<PropertyGroup>/,/<\/PropertyGroup>/ s|<Version>[0-9a-zA-Z.|-]*</Version>|<Version>${{ github.event.inputs.releaseVersion }}</Version>|g' ./Allure.Net.Commons/Allure.Net.Commons.csproj
sed -i -e '/<PropertyGroup>/,/<\/PropertyGroup>/ s|<Version>[0-9a-zA-Z.|-]*</Version>|<Version>${{ env.release_version }}</Version>|g' ./Allure.Net.Commons/Allure.Net.Commons.csproj
cat ./Allure.Net.Commons/Allure.Net.Commons.csproj
sed -i -e '/<PropertyGroup>/,/<\/PropertyGroup>/ s|<Version>[0-9a-zA-Z.|-]*</Version>|<Version>${{ github.event.inputs.releaseVersion }}</Version>|g' ./Allure.SpecFlowPlugin/Allure.SpecFlowPlugin.csproj
sed -i -e '/<PropertyGroup>/,/<\/PropertyGroup>/ s|<Version>[0-9a-zA-Z.|-]*</Version>|<Version>${{ env.release_version }}</Version>|g' ./Allure.SpecFlowPlugin/Allure.SpecFlowPlugin.csproj
cat ./Allure.SpecFlowPlugin/Allure.SpecFlowPlugin.csproj
sed -i -e '/<PropertyGroup>/,/<\/PropertyGroup>/ s|<Version>[0-9a-zA-Z.|-]*</Version>|<Version>${{ github.event.inputs.releaseVersion }}</Version>|g' ./Allure.XUnit/Allure.XUnit.csproj
sed -i -e '/<PropertyGroup>/,/<\/PropertyGroup>/ s|<Version>[0-9a-zA-Z.|-]*</Version>|<Version>${{ env.release_version }}</Version>|g' ./Allure.XUnit/Allure.XUnit.csproj
cat ./Allure.XUnit/Allure.XUnit.csproj
sed -i -e '/<PropertyGroup>/,/<\/PropertyGroup>/ s|<Version>[0-9a-zA-Z.|-]*</Version>|<Version>${{ env.release_version }}</Version>|g' ./Allure.NUnit/Allure.NUnit.csproj
cat ./Allure.NUnit/Allure.NUnit.csproj
- name: "Commit release version and create tag"
run: |
git commit -am "release ${{ github.event.inputs.releaseVersion }}"
git tag ${{ github.event.inputs.releaseVersion }}
git push origin ${{ github.event.inputs.releaseVersion }}
git commit -am "release ${{ env.release_version }}"
git tag ${{ env.release_version }}
git push origin ${{ env.release_version }}
- name: "Set next development version"
run: |
sed -i -e '/<PropertyGroup>/,/<\/PropertyGroup>/ s|<Version>[0-9a-zA-Z.|-]*</Version>|<Version>${{ github.event.inputs.nextVersion }}-SNAPSHOT</Version>|g' ./Allure.Net.Commons/Allure.Net.Commons.csproj
sed -i -e '/<PropertyGroup>/,/<\/PropertyGroup>/ s|<Version>[0-9a-zA-Z.|-]*</Version>|<Version>${{ inputs.nextVersion }}-SNAPSHOT</Version>|g' ./Allure.Net.Commons/Allure.Net.Commons.csproj
cat ./Allure.Net.Commons/Allure.Net.Commons.csproj
sed -i -e '/<PropertyGroup>/,/<\/PropertyGroup>/ s|<Version>[0-9a-zA-Z.|-]*</Version>|<Version>${{ github.event.inputs.nextVersion }}-SNAPSHOT</Version>|g' ./Allure.SpecFlowPlugin/Allure.SpecFlowPlugin.csproj
sed -i -e '/<PropertyGroup>/,/<\/PropertyGroup>/ s|<Version>[0-9a-zA-Z.|-]*</Version>|<Version>${{ inputs.nextVersion }}-SNAPSHOT</Version>|g' ./Allure.SpecFlowPlugin/Allure.SpecFlowPlugin.csproj
cat ./Allure.SpecFlowPlugin/Allure.SpecFlowPlugin.csproj
sed -i -e '/<PropertyGroup>/,/<\/PropertyGroup>/ s|<Version>[0-9a-zA-Z.|-]*</Version>|<Version>${{ github.event.inputs.nextVersion }}-SNAPSHOT</Version>|g' ./Allure.XUnit/Allure.XUnit.csproj
sed -i -e '/<PropertyGroup>/,/<\/PropertyGroup>/ s|<Version>[0-9a-zA-Z.|-]*</Version>|<Version>${{ inputs.nextVersion }}-SNAPSHOT</Version>|g' ./Allure.XUnit/Allure.XUnit.csproj
cat ./Allure.XUnit/Allure.XUnit.csproj
sed -i -e '/<PropertyGroup>/,/<\/PropertyGroup>/ s|<Version>[0-9a-zA-Z.|-]*</Version>|<Version>${{ inputs.nextVersion }}-SNAPSHOT</Version>|g' ./Allure.NUnit/Allure.NUnit.csproj
cat ./Allure.NUnit/Allure.NUnit.csproj
- name: "Commit next development version and push it"
run: |
git commit -am "set next development version ${{ github.event.inputs.nextVersion }}"
git commit -am "set next development version ${{ inputs.nextVersion }}"
git push origin ${{ github.ref }}
- name: "Publish Github Release"
uses: octokit/request-action@v2.x
with:
route: POST /repos/${{ github.repository }}/releases
tag_name: ${{ github.event.inputs.releaseVersion }}
tag_name: ${{ env.release_version }}
generate_release_notes: true
target_commitish: ${{ github.ref }}
prerelease: ${{ inputs.prerelease }}
env:
GITHUB_TOKEN: ${{ secrets.QAMETA_CI }}
28 changes: 28 additions & 0 deletions Allure.NUnit.Examples/Allure.NUnit.Examples.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<OutputType>Library</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Allure.NUnit\Allure.NUnit.csproj" />
</ItemGroup>

<ItemGroup>
<Resource Include="allureConfig.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="AllureIgnoredTest.cs" />
<None Include="./../img/Allure-Color.png" PackagePath="\">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
24 changes: 24 additions & 0 deletions Allure.NUnit.Examples/AllureAttachmentsTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.IO;
using Allure.Net.Commons;
using NUnit.Allure.Attributes;
using NUnit.Framework;

namespace Allure.NUnit.Examples
{
[AllureSuite("Tests - Attachments")]
public class AllureAttachmentsTest : BaseTest
{
[Test]
public void AttachmentSimpleTest()
{
Console.WriteLine("With Attachment");
Console.WriteLine(DateTime.Now);


AllureLifecycle.Instance.AddAttachment(
Path.Combine(TestContext.CurrentContext.TestDirectory, "allureConfig.json"),
"AllureConfig.json");
}
}
}
25 changes: 25 additions & 0 deletions Allure.NUnit.Examples/AllureBehaviorsTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using NUnit.Allure.Attributes;
using NUnit.Framework;

namespace Allure.NUnit.Examples
{
[AllureSuite("Tests - Behaviors")]
[AllureEpic("Epic")]
public class AllureBehaviorsTest : BaseTest
{
[Test]
[AllureFeature("f1")]
public void F1()
{
Assert.IsTrue(true);
}

[Test]
[AllureFeature("f2")]
[AllureStory("A")]
public void F2()
{
Assert.IsTrue(true);
}
}
}
35 changes: 35 additions & 0 deletions Allure.NUnit.Examples/AllureDiffTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Allure.Net.Commons;
using NUnit.Allure.Attributes;
using NUnit.Allure.Core;
using NUnit.Framework;

namespace Allure.NUnit.Examples
{
[AllureSuite("Tests - ScreenDiff")]
public class AllureDiffTest : BaseTest
{
[Test]
[AllureName("Simple test with diff")]
public void DiffTest()
{
AddDiffs();
}

[Test]
[AllureName("Diff test with step")]
public void DiffStepsTest()
{
AddDiffs();
AllureLifecycle.Instance.WrapInStep(() =>
{
AllureLifecycle.Instance.WrapInStep(() => { AddDiffs(); }, "Step Inside");
AddDiffs();
}, "StepOutSide");
}

public static void AddDiffs()
{
AllureLifecycle.Instance.AddScreenDiff("Allure-Color.png", "Allure-Color.png", "Allure-Color.png");
}
}
}
44 changes: 44 additions & 0 deletions Allure.NUnit.Examples/AllureIgnoredTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections;
using NUnit.Allure.Attributes;
using NUnit.Framework;

namespace Allure.NUnit.Examples
{
[AllureDisplayIgnored]
[AllureSuite("Tests - Ignored")]
public class AllureIgnoredTest : BaseTest
{
private static IEnumerable Data
{
get
{
yield return new TestCaseData("Ignore").SetName("{m}_NotExist");
yield return new TestCaseData("Ignore").SetName("{m}_NotExist ignored").Ignore("Test");
}
}

[Test]
[Ignore("Ignored test")]
public void IgnoredTest()
{
}


[Test]
[TestCase("a")]
[TestCase("b", Ignore = "Case")]
public void IgnoreTestWithTestCaseParams(string data)
{
Console.WriteLine(data);
}


[Test]
[TestCaseSource(typeof(AllureIgnoredTest), nameof(Data))]
public void IgnoreTestWithTestCaseData(string data)
{
Console.WriteLine(data);
}
}
}
41 changes: 41 additions & 0 deletions Allure.NUnit.Examples/AllureLabelTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Allure.Net.Commons;
using NUnit.Allure.Attributes;
using NUnit.Framework;

namespace Allure.NUnit.Examples
{
[AllureSuite("Tests - Labels")]
public class AllureLabelTest : BaseTest
{
[Test]
[AllureEpic("static epic")]
[AllureFeature("static feature")]
[AllureStory("static story")]
[AllureOwner("static owner")]
public void CommonStaticLabelTest()
{
}

[Test]
public void CommonDynamicLabelTest()
{
AllureLifecycle.Instance.UpdateTestCase(t => t.labels.Add(Label.Epic("dynamic epic")));
AllureLifecycle.Instance.UpdateTestCase(t => t.labels.Add(Label.Feature("dynamic feature")));
AllureLifecycle.Instance.UpdateTestCase(t => t.labels.Add(Label.Story("dynamic story")));
AllureLifecycle.Instance.UpdateTestCase(t => t.labels.Add(Label.Owner("dynamic owner")));
}

[Test]
[AllureLabel("custom", "static value")]
public void CustomStaticLabelTest()
{
}

[Test]
public void CustomDynamicLabelTest()
{
AllureLifecycle.Instance.UpdateTestCase(t =>
t.labels.Add(new Label {name = "custom", value = "dynamic value"}));
}
}
}
28 changes: 28 additions & 0 deletions Allure.NUnit.Examples/AllureLinkTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Allure.Net.Commons;
using NUnit.Allure.Attributes;
using NUnit.Framework;

namespace Allure.NUnit.Examples
{
[AllureSuite("Tests - Links")]
public class AllureLinkTest : BaseTest
{
[Test]
[AllureLink("GitHub", "https://github.com")]
[AllureLink("https://google.com")]
[AllureIssue("ISSUE-123")]
[AllureTms("TMS-123")]
public void StaticLinkTest()
{
}

[Test]
public void DynamicLinkTest()
{
AllureLifecycle.Instance.UpdateTestCase(t => t.links.Add(Link.Issue("ISSUE-123")));
AllureLifecycle.Instance.UpdateTestCase(t => t.links.Add(Link.Tms("TMS-123")));
AllureLifecycle.Instance.UpdateTestCase(t =>
t.links.Add(new Link {name = "GitHub", url = "https://github.com", type = "link"}));
}
}
}
56 changes: 56 additions & 0 deletions Allure.NUnit.Examples/AllureParametrizedTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.Collections;
using NUnit.Allure.Attributes;
using NUnit.Framework;

namespace Allure.NUnit.Examples
{
[AllureSuite("Tests - Parametrized")]
public class AllureParametrizedTest : BaseTest
{
public static IEnumerable TestCasesReturns
{
get
{
yield return new TestCaseData(12, 3).Returns(4);
yield return new TestCaseData(12, 2).Returns(6);
yield return new TestCaseData(12, 4).Returns(3);
}
}

[Test]
[AllureSubSuite("Returns")]
[AllureTag("TestCaseSource")]
[TestCaseSource(typeof(AllureParametrizedTest), nameof(TestCasesReturns))]
public int TestCaseSourceTest(int n, int d)
{
Console.WriteLine($"Validating {n} / {d} ");
return n / d;
}

[Test]
[Pairwise]
[AllureSubSuite("Pairwise")]
[AllureTag("Pairwise")]
public void PairwiseTest([Values("a", "b", "c")] string str)
{
Console.WriteLine(str);
}

[Test]
[Retry(5)]
[AllureSubSuite("Retry")]
[AllureTag("Retry")]
public void RetryTest()
{
}

[Test]
[AllureTag("Range")]
[AllureSubSuite("Range")]
public void RangeTest([Range(0, 2)] int value)
{
Console.WriteLine($"Got {value} from 0 to 2");
}
}
}
Loading