Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #34 from Rumyash/master
Browse files Browse the repository at this point in the history
Added support AllureDisplayIgnored for ignoring testcases. #24
  • Loading branch information
unickq authored Feb 14, 2021
2 parents b68c2e0 + 7a2021d commit b234a78
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/allure-nunit/Attributes/AllureDisplayIgnoredAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void AfterTest(ITest suite)
if (suite.HasChildren)
{
var ignoredTests =
suite.Tests.Where(t => t.RunState == RunState.Ignored || t.RunState == RunState.Skipped);
GetAllTests(suite).Where(t => t.RunState == RunState.Ignored || t.RunState == RunState.Skipped);
foreach (var test in ignoredTests)
{
AllureLifecycle.Instance.UpdateTestContainer(_ignoredContainerId, t => t.children.Add(test.Id));
Expand Down Expand Up @@ -71,6 +71,9 @@ public void AfterTest(ITest suite)
}
}

private static IEnumerable<ITest> GetAllTests(ITest test) =>
test.Tests.Concat(test.Tests.SelectMany(GetAllTests));

public ActionTargets Targets => ActionTargets.Suite;
}
}
25 changes: 25 additions & 0 deletions src/allure-nunit/TestSamples/TestClass1.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Threading.Tasks;
using Allure.Commons;
using NUnit.Allure.Attributes;
Expand Down Expand Up @@ -46,6 +47,21 @@ public void SimpleTestIgnored2()
{
}

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

[Test]
[TestCaseSource(typeof(TestClass1), nameof(Data))]
public void TestCaseData(string a)
{
Console.WriteLine(a);
}

[Test(Author = "unickq")]
[Category("SampleTag")]
[Description("OLOLO")]
Expand All @@ -57,5 +73,14 @@ public void SimpleTestFailed()
Console.WriteLine("Failed");
Assert.DoesNotThrow(() => { throw new Exception("I'm an exception"); });
}

private static IEnumerable Data
{
get
{
yield return new TestCaseData("Test").SetName("{m}_NotExist");
yield return new TestCaseData("Ignore").SetName("{m}_NotExist").Ignore("Test");
}
}
}
}
2 changes: 1 addition & 1 deletion src/allure-nunit/allure-nunit.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net45;netstandard20</TargetFrameworks>
<TargetFrameworks>net45;netstandard2.0</TargetFrameworks>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
<Version>1.0.0</Version>
Expand Down

0 comments on commit b234a78

Please sign in to comment.