This repository was archived by the owner on Aug 23, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Machine.Specifications.ConsoleRunner.Specs
Machine.Specifications.ConsoleRunner Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -267,6 +267,25 @@ public class when_running_two_spec_assemblies : ConsoleRunnerSpecs
267267 console . Lines . Count ( x => x . StartsWith ( "Contexts: " ) ) . Should ( ) . Be ( 1 ) ;
268268 }
269269
270+ [ Subject ( "Console runner" ) ]
271+ public class when_running_on_teamcity : ConsoleRunnerSpecs
272+ {
273+ Because of = ( ) =>
274+ program . Run ( new [ ] { GetPath ( @"Example.dll" ) , "--teamcity" } ) ;
275+
276+ It should_output_valid_durations = ( ) =>
277+ console . Lines . Count ( x => ExtractDuration ( x ) >= 0 ) . Should ( ) . Be ( 6 ) ;
278+ It should_not_output_invalid_durations = ( ) =>
279+ console . Lines . Count ( x => x . Contains ( "duration='-1'" ) ) . Should ( ) . Be ( 0 ) ;
280+
281+ private static long ? ExtractDuration ( string message )
282+ {
283+ var match = Regex . Match ( message , "duration='(\\ d+)'" ) ;
284+ if ( ! match . Success ) return null ;
285+ return long . Parse ( match . Groups [ 1 ] . Value ) ;
286+ }
287+ }
288+
270289 public class ConsoleRunnerSpecs
271290 {
272291 const string TeamCityIndicator = "TEAMCITY_PROJECT_NAME" ;
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ public ExitCode Run(string[] arguments)
102102 }
103103 }
104104
105- listeners . Add ( mainListener ) ;
105+ listeners . Insert ( 0 , mainListener ) ;
106106
107107 if ( options . AssemblyFiles . Count == 0 )
108108 {
You can’t perform that action at this time.
0 commit comments