Skip to content

Commit

Permalink
TC reporter for skipped for #215
Browse files Browse the repository at this point in the history
  • Loading branch information
lefthandedgoat committed Oct 13, 2015
1 parent a5705ca commit 679cfd4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
28 changes: 18 additions & 10 deletions src/canopy/reporters.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ type IReporter =
abstract member pass : unit -> unit
abstract member fail : Exception -> string -> byte [] -> string -> unit
abstract member todo : unit -> unit
abstract member skip : unit -> unit
abstract member skip : string -> unit
abstract member testEnd : string -> unit
abstract member describe : string -> unit
abstract member contextStart : string -> unit
abstract member contextEnd : string -> unit
abstract member summary : int -> int -> int -> int -> unit
abstract member summary : int -> int -> int -> int -> int -> unit
abstract member write : string -> unit
abstract member suggestSelectors : string -> string list -> unit
abstract member quit : unit -> unit
Expand Down Expand Up @@ -61,13 +61,17 @@ type ConsoleReporter() =

member this.contextEnd c = ()

member this.summary minutes seconds passed failed =
member this.summary minutes seconds passed failed skipped =
Console.WriteLine()
Console.WriteLine("{0} minutes {1} seconds to execute", minutes, seconds)
if failed = 0 then
Console.ForegroundColor <- ConsoleColor.Green
Console.WriteLine("{0} passed", passed)
Console.ResetColor()
if skipped > 0 then
Console.ForegroundColor <- ConsoleColor.Yellow
Console.WriteLine("{0} skipped", skipped)
Console.ResetColor()
if failed > 0 then
Console.ForegroundColor <- ConsoleColor.Red
Console.WriteLine("{0} failed", failed)
Expand All @@ -76,7 +80,7 @@ type ConsoleReporter() =
member this.write w = Console.WriteLine w

member this.suggestSelectors selector suggestions =
Console.ForegroundColor <- ConsoleColor.DarkYellow
Console.ForegroundColor <- ConsoleColor.Yellow
Console.WriteLine("Couldn't find any elements with selector '{0}', did you mean:", selector)
suggestions |> List.iter (fun suggestion -> Console.WriteLine("\t{0}", suggestion))
Console.ResetColor()
Expand All @@ -97,7 +101,10 @@ type ConsoleReporter() =

member this.todo () = ()

member this.skip () = ()
member this.skip id =
Console.ForegroundColor <- ConsoleColor.Yellow
Console.WriteLine("Skipped");
Console.ResetColor()

member this.setEnvironment env = ()

Expand Down Expand Up @@ -147,7 +154,7 @@ type TeamCityReporter() =
teamcityReport (sprintf "testSuiteFinished name='%s'" (tcFriendlyMessage c))
consoleReporter.contextEnd c
member this.summary minutes seconds passed failed = consoleReporter.summary minutes seconds passed failed
member this.summary minutes seconds passed failed skipped = consoleReporter.summary minutes seconds passed failed skipped
member this.write w = consoleReporter.write w
Expand All @@ -167,7 +174,7 @@ type TeamCityReporter() =
member this.todo () = ()
member this.skip () = ()
member this.skip id = teamcityReport (sprintf "testIgnored name='%s'" (tcFriendlyMessage id))
member this.setEnvironment env = ()
Expand Down Expand Up @@ -260,9 +267,9 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string) =
this.swallowedJS (sprintf "addTimeToContext ('%s', '%im %is');" context ellapsed.Minutes ellapsed.Seconds)
consoleReporter.contextEnd c

member this.summary minutes seconds passed failed =
member this.summary minutes seconds passed failed skipped =
this.swallowedJS (sprintf "setTotalTime ('%im %is');" minutes seconds)
consoleReporter.summary minutes seconds passed failed
consoleReporter.summary minutes seconds passed failed skipped

member this.write w =
this.swallowedJS (sprintf "addMessageToTest ('%s', '%s');" context w)
Expand Down Expand Up @@ -311,8 +318,9 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string) =
member this.todo () =
this.swallowedJS (sprintf "updateTestInContext('%s', 'Todo', '%s');" context "")

member this.skip () =
member this.skip id =
this.swallowedJS (sprintf "updateTestInContext('%s', 'Skip', '%s');" context "")
consoleReporter.skip id

member this.setEnvironment env =
environment <- env
11 changes: 8 additions & 3 deletions src/canopy/runner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ let ( &&&&& ) description f =
let lastSuite = incrementLastTestSuite()
lastSuite.Always <- lastSuite.Always @ [Test(description, f, lastSuite.TotalTestsCount)]
let mutable passedCount = 0
let mutable skippedCount = 0
let mutable failedCount = 0
let mutable contextFailed = false
let mutable failedContexts : string list = []
Expand All @@ -60,6 +61,10 @@ let pass () =
passedCount <- passedCount + 1
reporter.pass ()

let skip id =
skippedCount <- skippedCount + 1
reporter.skip id

let fail (ex : Exception) id =
if skipAllTestsOnFailure = true || skipRemainingTestsInContextOnFailure = true then skipNextTest <- true
try
Expand Down Expand Up @@ -97,9 +102,9 @@ let run () =
if System.Object.ReferenceEquals(test.Func, todo) then
reporter.todo ()
else if System.Object.ReferenceEquals(test.Func, skipped) then
reporter.skip ()
skip test.Id
else if skipNextTest = true then
reporter.skip ()
skip test.Id
else
try
try
Expand Down Expand Up @@ -157,7 +162,7 @@ let run () =
history.save failedContexts

stopWatch.Stop()
reporter.summary stopWatch.Elapsed.Minutes stopWatch.Elapsed.Seconds passedCount failedCount
reporter.summary stopWatch.Elapsed.Minutes stopWatch.Elapsed.Seconds passedCount failedCount skippedCount
reporter.suiteEnd()

let runFor browsers =
Expand Down

0 comments on commit 679cfd4

Please sign in to comment.