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

Commit

Permalink
Category fix for #11 v2
Browse files Browse the repository at this point in the history
  • Loading branch information
unickq committed Aug 16, 2018
1 parent e4e0609 commit 6808ba5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 29 deletions.
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 1.0.0.{build}
version: 1.0.2.{build}

environment:
nugetVersion: 1.0.0
nugetVersion: 1.0.2

init:
- ps: Update-AppveyorBuild -Version $env:nugetVersion
Expand Down
55 changes: 34 additions & 21 deletions src/Core/AllureNUnitHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public void StopAll(bool isWrapedIntoStep)
StopTestContainer(listSetups, listTeardowns);
}


private void StopTestCase()
{
UpdateTestDataFromAttributes();
Expand Down Expand Up @@ -262,28 +262,18 @@ internal static Status GetNunitStatus()
return Status.passed;
}


private void UpdateTestDataFromAttributes()
{
if (_test.Properties.ContainsKey(PropertyNames.Author))
AllureLifecycle.UpdateTestCase(x =>
x.labels.Add(Label.Owner(_test.Properties.Get(PropertyNames.Author).ToString())));

if (_test.Properties.ContainsKey(PropertyNames.Description))
AllureLifecycle.UpdateTestCase(x =>
x.description += $"{_test.Properties.Get(PropertyNames.Description).ToString()}\n");

if (GetTestFixture(_test).Properties.ContainsKey(PropertyNames.Category))
AllureLifecycle.UpdateTestCase(x =>
x.labels.Add(Label.Tag(GetTestFixture(_test).Properties.Get(PropertyNames.Category).ToString())));

if (_test.Parent.Properties.ContainsKey(PropertyNames.Category))
AllureLifecycle.UpdateTestCase(x =>
x.labels.Add(Label.Tag(_test.Parent.Properties.Get(PropertyNames.Category).ToString())));

if (_test.Properties.ContainsKey(PropertyNames.Category))
AllureLifecycle.UpdateTestCase(x =>
x.labels.Add(Label.Tag(_test.Properties.Get(PropertyNames.Category).ToString())));

foreach (var p in GetTestProperties(PropertyNames.Description))
AllureLifecycle.UpdateTestCase(x => x.description += $"{p}\n");

foreach (var p in GetTestProperties(PropertyNames.Author))
AllureLifecycle.UpdateTestCase(x => x.labels.Add(Label.Owner(p)));

foreach (var p in GetTestProperties(PropertyNames.Category))
AllureLifecycle.UpdateTestCase(x => x.labels.Add(Label.Tag(p)));

var attributes = _test.Method.GetCustomAttributes<NUnitAttribute>(true).ToList();

foreach (var attribute in attributes)
Expand Down Expand Up @@ -334,6 +324,29 @@ private void UpdateTestDataFromAttributes()
}
}

private IEnumerable<string> GetTestProperties(string name)
{
var list = new List<string>();
var currentTest = _test;
while (currentTest.GetType() != typeof(TestSuite))
{
if (currentTest.Properties.ContainsKey(name))
{
if (currentTest.Properties[name].Count > 0)
{
for (var i = 0; i < currentTest.Properties[name].Count; i++)
{
list.Add(currentTest.Properties[name][i].ToString());
}
}
}

currentTest = currentTest.Parent;
}

return list;
}

public void WrapInStep(Action action, string stepName = "")
{
AllureLifecycle.WrapInStep(action, stepName);
Expand Down
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("f45061ce-868e-45db-963f-84397f4f1653")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2.0")]

[assembly: Parallelizable(ParallelScope.Children)]
8 changes: 4 additions & 4 deletions src/allure-nunit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<PropertyGroup>
<TargetFrameworks>net45;netstandard20</TargetFrameworks>
<AssemblyVersion>0.2.3</AssemblyVersion>
<FileVersion>0.2.3</FileVersion>
<Version>0.2.3</Version>
<AssemblyVersion>1.0.2</AssemblyVersion>
<FileVersion>1.0.2</FileVersion>
<Version>1.0.2</Version>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Authors>Nick Chursin</Authors>
<Description>NUnit attributes extenstions for Allure</Description>
Expand All @@ -15,7 +15,7 @@
<RepositoryUrl>https://github.com/unickq/allure-nunit</RepositoryUrl>
<PackageLicenseUrl>https://github.com/unickq/allure-nunit/blob/master/LICENSE</PackageLicenseUrl>
<PackageTags>nunit allure</PackageTags>
<PackageReleaseNotes>Rewriting NUnit for more features</PackageReleaseNotes>
<PackageReleaseNotes>TestFixture(Category) fix</PackageReleaseNotes>
<PackageIconUrl>https://raw.githubusercontent.com/unickq/allure-nunit/master/logo.png</PackageIconUrl>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
Expand Down

0 comments on commit 6808ba5

Please sign in to comment.