@@ -17,9 +17,7 @@ internal class Program
17
17
private Logger _logger ;
18
18
private ExtentReports _extent = new ExtentReports ( ) ;
19
19
private int _filesProcessed = 0 ;
20
-
21
- [ Option ( ShortName = "p" ) ]
22
- private TestFramework Parser { get ; set ; } = TestFramework . NUnit ;
20
+ static private int _errorCount ;
23
21
24
22
[ Option ( ShortName = "i" ) ]
25
23
private string TestRunnerResultsFile { get ; set ; }
@@ -40,9 +38,10 @@ internal class Program
40
38
private bool Merge { get ; set ; } = false ;
41
39
42
40
43
- private static void Main ( string [ ] args )
41
+ private static int Main ( string [ ] args )
44
42
{
45
43
CommandLineApplication . Execute < Program > ( args ) ;
44
+ return _errorCount ;
46
45
}
47
46
48
47
private void OnExecute ( )
@@ -52,41 +51,45 @@ private void OnExecute()
52
51
53
52
string output = string . IsNullOrWhiteSpace ( Output ) ? $ ".\\ { DefaultBaseDirectory } " : Output ;
54
53
55
- if ( ! string . IsNullOrEmpty ( TestRunnerResultsDirectory ) && File . GetAttributes ( TestRunnerResultsDirectory ) == FileAttributes . Directory && Parser . Equals ( TestFramework . NUnit ) )
54
+ if ( ! string . IsNullOrEmpty ( TestRunnerResultsDirectory ) &&
55
+ File . GetAttributes ( TestRunnerResultsDirectory ) . HasFlag ( FileAttributes . Directory ) )
56
56
{
57
- string filePattern = "*." + KnownFileExtensions . GetExtension ( Parser ) ;
57
+ string filePattern = "*.xml" ;
58
58
_logger . WriteLine ( LoggingLevel . Normal , $ "Getting test runner result files in folder '{ TestRunnerResultsDirectory } ' matching pattern '{ filePattern } ' ...") ;
59
59
60
60
List < string > files = Directory . GetFiles ( TestRunnerResultsDirectory , filePattern , SearchOption . AllDirectories ) . ToList ( ) ;
61
61
62
62
if ( Merge )
63
63
{
64
- files . ForEach ( x => ProcessSingle ( x , output , true ) ) ;
64
+ files . ForEach ( x =>
65
+ {
66
+ _errorCount += ProcessSingle ( x , output , true ) ;
67
+ } ) ;
65
68
}
66
69
else
67
70
{
68
71
files . ForEach ( x =>
69
72
{
70
73
var dir = Path . Combine ( output , Path . GetFileNameWithoutExtension ( x ) ) ;
71
- ProcessSingle ( x , dir , false ) ;
74
+ _errorCount += ProcessSingle ( x , dir , false ) ;
72
75
} ) ;
73
76
}
74
77
}
75
78
76
79
if ( ! string . IsNullOrWhiteSpace ( TestRunnerResultsFile ) )
77
80
{
78
- ProcessSingle ( TestRunnerResultsFile , output , true ) ;
81
+ _errorCount += ProcessSingle ( TestRunnerResultsFile , output , true ) ;
79
82
}
80
83
81
84
if ( _filesProcessed == 0 )
82
85
{
83
86
_logger . WriteLine ( LoggingLevel . Normal , "Nothing to do!" ) ;
84
87
}
85
88
86
- _logger . WriteLine ( LoggingLevel . Verbose , "extentreports-cli finished." ) ;
89
+ _logger . WriteLine ( LoggingLevel . Verbose , $ "extentreports-cli finished. { _errorCount } errors .") ;
87
90
}
88
91
89
- private void ProcessSingle ( string testResultsFilePath , string output , bool merge = false )
92
+ private int ProcessSingle ( string testResultsFilePath , string output , bool merge = false )
90
93
{
91
94
_logger . WriteLine ( LoggingLevel . Normal , $ "Parsing test runner result file '{ testResultsFilePath } ' ...") ;
92
95
@@ -103,10 +106,12 @@ private void ProcessSingle(string testResultsFilePath, string output, bool merge
103
106
}
104
107
105
108
new NUnitParser ( _extent ) . ParseTestRunnerOutput ( testResultsFilePath ) ;
109
+ new JUnitParser ( _extent ) . ParseTestRunnerOutput ( testResultsFilePath ) ;
106
110
_extent . Flush ( ) ;
107
111
_filesProcessed ++ ;
108
112
109
113
_logger . WriteLine ( LoggingLevel . Normal , $ "Report for '{ testResultsFilePath } ' is complete.") ;
114
+ return _extent . Stats . ChildCountFail ;
110
115
}
111
116
112
117
private void InitializeReporter ( ExtentReports extent , string path )
0 commit comments