55using Allure . Net . Commons ;
66using Allure . XUnit ;
77using Allure . Xunit . Attributes ;
8+ using Xunit ;
89using Xunit . Abstractions ;
9- using Xunit . Sdk ;
1010
1111namespace Allure . Xunit
1212{
@@ -49,17 +49,24 @@ public static void StartTestCase(ITestCaseMessage testCaseMessage)
4949 testResults . TestResult = new ( )
5050 {
5151 uuid = uuid ,
52- name = testCase . DisplayName ,
52+ name = BuildName ( testCase ) ,
5353 historyId = testCase . DisplayName ,
54- fullName = testCase . DisplayName ,
54+ fullName = BuildFullName ( testCase ) ,
5555 labels = new ( )
5656 {
5757 Label . Thread ( ) ,
5858 Label . Host ( ) ,
5959 Label . TestClass ( testCase . TestMethod . TestClass . Class . Name ) ,
6060 Label . TestMethod ( testCase . DisplayName ) ,
6161 Label . Package ( testCase . TestMethod . TestClass . Class . Name )
62- }
62+ } ,
63+ parameters = testCase . TestMethod . Method . GetParameters ( )
64+ . Zip ( testCase . TestMethodArguments ?? Array . Empty < object > ( ) , ( param , value ) => new Parameter
65+ {
66+ name = param . Name ,
67+ value = value ? . ToString ( ) ?? "null"
68+ } )
69+ . ToList ( )
6370 } ;
6471 UpdateTestDataFromAttributes ( testResults . TestResult , testCase ) ;
6572 AllureLifecycle . Instance . StartTestCase ( testResults . TestResultContainer . uuid , testResults . TestResult ) ;
@@ -224,8 +231,7 @@ private static void UpdateTestDataFromAttributes(TestResult testResult, ITestCas
224231 case AllureDescriptionAttribute descriptionAttribute :
225232 testResult . description = descriptionAttribute . Description ;
226233 break ;
227-
228-
234+
229235 case AllureIdAttribute allureIdAttribute :
230236 var allureIdLabel = new Label { name = "ALLURE_ID" , value = allureIdAttribute . AllureId } ;
231237 testResult . labels . AddDistinct ( allureIdLabel , false ) ;
@@ -242,5 +248,36 @@ private static void UpdateTestDataFromAttributes(TestResult testResult, ITestCas
242248 }
243249 }
244250 }
251+
252+ private static string BuildName ( ITestCase testCase )
253+ {
254+ var factAttribute = testCase . TestMethod . Method . GetCustomAttributes ( typeof ( FactAttribute ) ) . SingleOrDefault ( ) ;
255+ if ( factAttribute is null )
256+ {
257+ return BuildFullName ( testCase ) ;
258+ }
259+
260+ var displayName = factAttribute . GetNamedArgument < string > ( "DisplayName" ) ;
261+ if ( string . IsNullOrWhiteSpace ( displayName ) )
262+ {
263+ return BuildFullName ( testCase ) ;
264+ }
265+
266+ return displayName ;
267+ }
268+
269+ private static string BuildFullName ( ITestCase testCase )
270+ {
271+ var parameters = testCase . TestMethod . Method
272+ . GetParameters ( )
273+ . Select ( parameter =>
274+ $ "{ parameter . ParameterType . ToRuntimeType ( ) . GetFullFormattedTypeName ( ) } { parameter . Name } ")
275+ . ToArray ( ) ;
276+ var parametersSegment = parameters . Any ( )
277+ ? $ "({ string . Join ( ", " , parameters ) } )"
278+ : string . Empty ;
279+
280+ return $ "{ testCase . TestMethod . TestClass . Class . Name } .{ testCase . TestMethod . Method . Name } { parametersSegment } ";
281+ }
245282 }
246283}
0 commit comments