Skip to content
Open
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
21 changes: 20 additions & 1 deletion Allure.XUnit/AllureXunitHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private static void AddDistinct(this List<Label> labels, string labelName, strin

private static void UpdateTestDataFromAttributes(TestResult testResult, ITestCase testCase)
{
var classAttributes = testCase.TestMethod.TestClass.Class.GetCustomAttributes(typeof(IAllureInfo));
var classAttributes = GetCustomAttributesRecursive(testCase.TestMethod.TestClass.Class, typeof(IAllureInfo));
var methodAttributes = testCase.TestMethod.Method.GetCustomAttributes(typeof(IAllureInfo));

foreach (var attribute in classAttributes.Concat(methodAttributes))
Expand Down Expand Up @@ -279,5 +279,24 @@ private static string BuildFullName(ITestCase testCase)

return $"{testCase.TestMethod.TestClass.Class.Name}.{testCase.TestMethod.Method.Name}{parametersSegment}";
}

private static IEnumerable<IAttributeInfo> GetCustomAttributesRecursive(ITypeInfo typeInfo, Type attributeType)
{
foreach (var type in GetInheritanceTree(typeInfo).Reverse())
{
foreach (var attribute in type.GetCustomAttributes(attributeType.AssemblyQualifiedName))
yield return attribute;
}

static IEnumerable<ITypeInfo> GetInheritanceTree(ITypeInfo typeInfo)
{
var currentType = typeInfo;
while (currentType.ToRuntimeType() != typeof(object))
{
yield return currentType;
currentType = currentType.BaseType;
}
}
}
}
}