Skip to content

Commit

Permalink
Implement requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
delatrie committed Oct 12, 2023
1 parent 865b0d0 commit 626170e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 84 deletions.
8 changes: 1 addition & 7 deletions Allure.NUnit/Core/AllureNUnitHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,9 @@ static void SetIdentifiers(ITest test, TestResult testResult)
if (AllureLifecycle.AllureConfiguration.UseLegacyIds)
{
SetLegacyIdentifiers(test, testResult);
return;
}
else
{
SetNewIdentifiers(test, testResult);
}
}

static void SetNewIdentifiers(ITest test, TestResult testResult)
{
testResult.uuid = IdFunctions.CreateUUID();
testResult.fullName = IdFunctions.CreateFullName(
test.Method.MethodInfo
Expand Down
60 changes: 31 additions & 29 deletions Allure.Net.Commons.Tests/FunctionTests/IdTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,63 +52,64 @@ internal void GenericMethodOfGenericClass<V>(List<T> _, List<V> __) { }

[TestCase(
nameof(MyClass.ParameterlessMethod),
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests." +
"IdTests+MyClass.ParameterlessMethod()",
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass.ParameterlessMethod()",
TestName = "ParameterlessMethod"
)]
[TestCase(
nameof(MyClass.MethodWithParameterOfBuiltInType),
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests." +
"IdTests+MyClass.MethodWithParameterOfBuiltInType(System.Int32)",
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass" +
".MethodWithParameterOfBuiltInType(System.Int32)",
TestName = "MethodWithParameterOfBuiltInType"
)]
[TestCase(
nameof(MyClass.MethodWithParameterOfUserType),
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests." +
"IdTests+MyClass.MethodWithParameterOfUserType(Allure.Net." +
"Commons.Tests:Allure.Net.Commons.Tests.FunctionTests." +
"IdTests+MyClass)",
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass" +
".MethodWithParameterOfUserType(" +
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass" +
")",
TestName = "MethodWithParameterOfUserType"
)]
[TestCase(
nameof(MyClass.MethodWithTwoParameters),
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests." +
"IdTests+MyClass.MethodWithTwoParameters(System.Int32,Allure." +
"Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests." +
"IdTests+MyClass)",
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass" +
".MethodWithTwoParameters(" +
"System.Int32," +
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass" +
")",
TestName = "MethodWithTwoParameters"
)]
[TestCase(
nameof(MyClass.MethodWithRefParameter),
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests." +
"IdTests+MyClass.MethodWithRefParameter(System.Int32&)",
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass" +
".MethodWithRefParameter(System.Int32&)",
TestName = "MethodWithRefParameter"
)]
[TestCase(
nameof(MyClass.MethodWithGenericParameter),
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests." +
"IdTests+MyClass.MethodWithGenericParameter[T]()",
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass" +
".MethodWithGenericParameter[T]()",
TestName = "MethodWithGenericParameter"
)]
[TestCase(
nameof(MyClass.MethodWithArgumentOfGenericType),
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests." +
"IdTests+MyClass.MethodWithArgumentOfGenericType[T](T)",
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass" +
".MethodWithArgumentOfGenericType[T](T)",
TestName = "MethodWithArgumentOfGenericType"
)]
[TestCase(
nameof(MyClass.MethodWithArgumentOfTypeParametrizedByGenericType),
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests." +
"IdTests+MyClass.MethodWithArgumentOfTypeParametrizedByGenericType" +
"[T](System.Collections.Generic.Dictionary`2[System.Int32,T])",
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass" +
".MethodWithArgumentOfTypeParametrizedByGenericType[T](" +
"System.Collections.Generic.Dictionary`2[System.Int32,T]" +
")",
TestName = "MethodWithArgumentOfTypeParametrizedByGenericType"
)]
[TestCase(
nameof(MyClass.MethodWithArgumentOfGenericUserType),
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests." +
"IdTests+MyClass.MethodWithArgumentOfGenericUserType" +
"[T](Allure.Net.Commons.Tests:Allure.Net.Commons.Tests." +
"FunctionTests.IdTests+MyClass`1[T])",
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass" +
".MethodWithArgumentOfGenericUserType[T](" +
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass`1[T]" +
")",
TestName = "MethodWithArgumentOfGenericUserType"
)]
public void FullNameFromMethod(string methodName, string expectedFullName)
Expand All @@ -134,10 +135,11 @@ public void TestFullNameFromMethodOfNestedGenericClass()
var actualFullName = IdFunctions.CreateFullName(method);

Assert.That(actualFullName, Is.EqualTo(
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests." +
"IdTests+MyClass`1[T].GenericMethodOfGenericClass[V]" +
"(System.Collections.Generic.List`1[T],System.Collections." +
"Generic.List`1[V])"
"Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass`1[T]" +
".GenericMethodOfGenericClass[V](" +
"System.Collections.Generic.List`1[T]," +
"System.Collections.Generic.List`1[V]" +
")"
));
}

Expand Down
2 changes: 1 addition & 1 deletion Allure.Net.Commons/Steps/AllureStepAspect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private static void PassFixture(MethodBase metadata)
if (metadata.GetCustomAttribute<AbstractBeforeAttribute>(inherit: true) != null ||
metadata.GetCustomAttribute<AbstractAfterAttribute>(inherit: true) != null)
{
CoreStepsHelper.PassFixture(result => result.status = Status.passed);
CoreStepsHelper.PassFixture();
}
}

Expand Down
40 changes: 12 additions & 28 deletions Allure.SpecFlowPlugin/PluginHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,36 +261,9 @@ string parametersHash
scenarioTitle,
parametersHash
);
return;
}
else
{
SetNewTestResultIdentifiers(
testRunnerManager,
featureInfo,
testResult,
scenarioTitle
);
}
}

static void SetLegacyTestResultIdentifiers(
TestResult testResult,
string scenarioTitle,
string parametersHash
)
{
testResult.uuid = NewId();
testResult.historyId = scenarioTitle + parametersHash;
testResult.fullName = scenarioTitle;
}

static void SetNewTestResultIdentifiers(
ITestRunnerManager testRunnerManager,
FeatureInfo featureInfo,
TestResult testResult,
string scenarioTitle
)
{
testResult.uuid = IdFunctions.CreateUUID();
testResult.fullName = CreateFullName(
testRunnerManager,
Expand All @@ -306,6 +279,17 @@ string scenarioTitle
);
}

static void SetLegacyTestResultIdentifiers(
TestResult testResult,
string scenarioTitle,
string parametersHash
)
{
testResult.uuid = NewId();
testResult.historyId = scenarioTitle + parametersHash;
testResult.fullName = scenarioTitle;
}

static string CreateFullName(
ITestRunnerManager testRunnerManager,
FeatureInfo featureInfo,
Expand Down
29 changes: 10 additions & 19 deletions Allure.XUnit/AllureXunitHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,17 @@ TestResult testResult
if (AllureLifecycle.Instance.AllureConfiguration.UseLegacyIds)
{
SetLegacyTestResultIdentifiers(testCase, displayName, testResult);
return;
}
else
{
SetNewTestResultIdentifiers(testCase, testResult);
}

testResult.uuid = IdFunctions.CreateUUID();
testResult.fullName = IdFunctions.CreateFullName(
testCase.TestMethod.Method.ToRuntimeMethod()
);
testResult.testCaseId = IdFunctions.CreateTestCaseId(
testResult.fullName
);
// historyId is set later, when test arguments are received
}

static void UpdateHistoryId(TestResult testResult)
Expand All @@ -259,21 +265,6 @@ TestResult testResult
testResult.historyId = displayName;
}

static void SetNewTestResultIdentifiers(
ITestCase testCase,
TestResult testResult
)
{
testResult.uuid = IdFunctions.CreateUUID();
testResult.fullName = IdFunctions.CreateFullName(
testCase.TestMethod.Method.ToRuntimeMethod()
);
testResult.testCaseId = IdFunctions.CreateTestCaseId(
testResult.fullName
);
// historyId is set later, when test arguments are received
}

static void UpdateTestDataFromAttributes(
TestResult testResult,
ITestMethod method
Expand Down

0 comments on commit 626170e

Please sign in to comment.