44using System . Collections . Generic ;
55using System . Linq ;
66using GoogleTestAdapter . Common ;
7+ using GoogleTestAdapter . Helpers ;
78using GoogleTestAdapter . Model ;
89using GoogleTestAdapter . TestResults ;
910
@@ -23,7 +24,18 @@ public TestResultCollector(ILogger logger, string threadName)
2324 public List < TestResult > CollectTestResults ( IEnumerable < TestCase > testCasesRun , List < string > consoleOutput , TestCase crashedTestCase )
2425 {
2526 var testResults = new List < TestResult > ( ) ;
26- TestCase [ ] arrTestCasesRun = testCasesRun as TestCase [ ] ?? testCasesRun . ToArray ( ) ;
27+
28+ bool isFixtureMethodCase ( TestCase tc )
29+ {
30+ var testType = tc . Traits . FirstOrDefault ( t => t . Name . Equals ( TestCases . TestCaseDescriptor . TestTypeTraitName ) ) ;
31+ return testType != null && Enum . TryParse ( testType . Value , out TestCases . TestCaseDescriptor . TestTypes type ) && type == TestCases . TestCaseDescriptor . TestTypes . Fixture ;
32+ }
33+
34+ ( var fixtureMethods , var remainingCases ) = testCasesRun . Partition ( isFixtureMethodCase ) ;
35+ TestCase [ ] arrTestCasesRun = remainingCases as TestCase [ ] ?? remainingCases . ToArray ( ) ;
36+ TestCase [ ] arrFixtureMethods = fixtureMethods as TestCase [ ] ?? fixtureMethods . ToArray ( ) ;
37+
38+ CreateFixtureMethodResults ( arrFixtureMethods , testResults ) ;
2739
2840 var consoleParser = new StandardOutputTestResultParser ( arrTestCasesRun , consoleOutput , _logger ) ;
2941 if ( testResults . Count < arrTestCasesRun . Length )
@@ -81,11 +93,20 @@ private void CreateMissingResults(TestCase[] testCases, TestCase crashedTestCase
8193 _logger . DebugInfo ( String . Format ( Resources . CreatedTestResults , _threadName , testCases . Length ) ) ;
8294 }
8395
96+ private void CreateFixtureMethodResults ( TestCase [ ] testCases , List < TestResult > testResults )
97+ {
98+ foreach ( TestCase testCase in testCases )
99+ {
100+ testResults . Add ( StandardOutputTestResultParser . CreatePassedTestResult ( testCase , TimeSpan . FromMilliseconds ( 0 ) ) ) ;
101+ }
102+ }
103+
84104 private void ReportSuspiciousTestCases ( TestCase [ ] testCases )
85105 {
86106 string testCasesAsString = string . Join ( Environment . NewLine , testCases . Select ( tc => tc . DisplayName ) ) ;
87107 _logger . DebugWarning ( String . Format ( Resources . TestCaseNotRun , _threadName , testCases . Length , Environment . NewLine , testCasesAsString ) ) ;
88108 }
89109
110+
90111 }
91112}
0 commit comments