From a5cf7b1b1a66cd2769fe87385c4b9efefedff50c Mon Sep 17 00:00:00 2001 From: Chris Holt Date: Mon, 15 Jun 2015 22:12:57 -0500 Subject: [PATCH] Changes for #202, update html reporter, update to selenium 2.46 --- RELEASE_NOTES.md | 4 +++ docs/files/reporttemplate.html | 31 ++++++++++++------- nuget/canopy.nuspec | 4 +-- src/canopy/AssemblyInfo.fs | 6 ++-- src/canopy/canopy.fsproj | 7 ++--- src/canopy/packages.config | 4 +-- src/canopy/reporters.fs | 20 +++++++----- src/canopy/runner.fs | 4 +-- src/sampleprojectstructure/packages.config | 4 +-- .../sampleprojectstructure.fsproj | 6 +++- tests/basictests/basictests.fsproj | 4 +-- tests/basictests/packages.config | 4 +-- .../documentationtests.fsproj | 4 +-- tests/documentationtests/packages.config | 4 +-- 14 files changed, 63 insertions(+), 43 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 35f968ac..2b26fa10 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -144,3 +144,7 @@ #### 0.9.26 - June 1 2015 * Fixed bug where after wouldn't run following a failed test [Issue #197](https://github.com/lefthandedgoat/canopy/issues/197) + +#### 0.9.27 - June 15 2015 +* Improved Html reporter to have stack trace, error message and url of failing page [Issue #202](https://github.com/lefthandedgoat/canopy/issues/202) +* Updated to Selenium 2.46 diff --git a/docs/files/reporttemplate.html b/docs/files/reporttemplate.html index 1b4e9c3c..099d2c56 100644 --- a/docs/files/reporttemplate.html +++ b/docs/files/reporttemplate.html @@ -91,35 +91,45 @@ var addToContext = function (context, passFailSkip, testName, image) { var ctx = $('#contexts tr[data-context="' + context + '"]'); if (passFailSkip === "Pass") { - ctx.next('tr').find('table').last('tr').append('' + testName + ''); + ctx.next('tr').find('table').last('tr').append('
' + testName + '
'); if (ctx.hasClass("error") === false) { ctx.removeClass("warning").removeClass("info").addClass("success"); } } if (passFailSkip === "Fail") { - ctx.next('tr').find('table').last('tr').append('' + testName + ''); + ctx.next('tr').find('table').last('tr').append('
' + testName + '
'); ctx.removeClass("success").removeClass("warning").removeClass("info").addClass("error"); } if (passFailSkip === "Todo") { - ctx.next('tr').find('table').last('tr').append('' + testName + ''); + ctx.next('tr').find('table').last('tr').append('
' + testName + '
'); if (ctx.hasClass("error") === false && ctx.hasClass("info") === false && ctx.hasClass("success") === false){ ctx.addClass("warning"); } } if (passFailSkip === "Skip") { - ctx.next('tr').find('table').last('tr').append('' + testName + ''); + ctx.next('tr').find('table').last('tr').append('
' + testName + '
'); if (ctx.hasClass("error") === false && ctx.hasClass("warning") === false && ctx.hasClass("success") === false){ ctx.addClass("info"); } } if(image !== "") { - ctx.next('tr').find('table').find('tr').last().find('td').last().append('') + ctx.next('tr').find('table').find('tr').last().find('td').last().append('
') } recalculateTotals(); }; + var addUrlToTest = function (context, url) { + var ctx = $('#contexts tr[data-context="' + context + '"]'); + ctx.next('tr').find('table').last('tr').find('.test').last().after('
' + url + '
'); + }; + + var addStackToTest = function (context, stack) { + var ctx = $('#contexts tr[data-context="' + context + '"]'); + ctx.next('tr').find('table').last('tr').find('.test').last().after('
' + stack + '
'); + }; + var collapseContextsExcept = function (context) { var ctxs = $('#contexts tr.result[data-owning-context !="' + context + '"]'); ctxs.each(function () { @@ -127,14 +137,13 @@ }); }; - $(document).ready(function() { - + $(document).ready(function() { var showHide = function(next) { if (next.is(":visible")) { - next.hide(); - } else { - next.show(); - } + next.hide(); + } else { + next.show(); + } }; //wire up to existing contexts on the page diff --git a/nuget/canopy.nuspec b/nuget/canopy.nuspec index 4ce471eb..ed1dc4e7 100644 --- a/nuget/canopy.nuspec +++ b/nuget/canopy.nuspec @@ -13,8 +13,8 @@ @tags@ - - + + diff --git a/src/canopy/AssemblyInfo.fs b/src/canopy/AssemblyInfo.fs index b9b61e36..7163c132 100644 --- a/src/canopy/AssemblyInfo.fs +++ b/src/canopy/AssemblyInfo.fs @@ -4,9 +4,9 @@ open System.Reflection [] [] [] -[] -[] +[] +[] do () module internal AssemblyVersionInformation = - let [] Version = "0.9.26" + let [] Version = "0.9.27" diff --git a/src/canopy/canopy.fsproj b/src/canopy/canopy.fsproj index 797be9d8..59e78106 100644 --- a/src/canopy/canopy.fsproj +++ b/src/canopy/canopy.fsproj @@ -68,9 +68,6 @@ ..\..\packages\FSharp.Core.3.0.2\lib\net40\FSharp.Core.dll True - - False - ..\..\packages\Newtonsoft.Json.6.0.6\lib\net40\Newtonsoft.Json.dll @@ -87,11 +84,11 @@ - ..\..\packages\Selenium.WebDriver.2.45.0\lib\net40\WebDriver.dll + ..\..\packages\Selenium.WebDriver.2.46.0\lib\net40\WebDriver.dll True - ..\..\packages\Selenium.Support.2.45.0\lib\net40\WebDriver.Support.dll + ..\..\packages\Selenium.Support.2.46.0\lib\net40\WebDriver.Support.dll True diff --git a/src/canopy/packages.config b/src/canopy/packages.config index a51bcb65..3d7c0b06 100644 --- a/src/canopy/packages.config +++ b/src/canopy/packages.config @@ -2,7 +2,7 @@ - - + + \ No newline at end of file diff --git a/src/canopy/reporters.fs b/src/canopy/reporters.fs index 69ce82e3..44096994 100644 --- a/src/canopy/reporters.fs +++ b/src/canopy/reporters.fs @@ -7,7 +7,7 @@ open types type IReporter = abstract member testStart : string -> unit abstract member pass : unit -> unit - abstract member fail : Exception -> string -> byte [] -> unit + abstract member fail : Exception -> string -> byte [] -> string -> unit abstract member todo : unit -> unit abstract member skip : unit -> unit abstract member testEnd : string -> unit @@ -29,11 +29,13 @@ type ConsoleReporter() = Console.WriteLine("Passed"); Console.ResetColor() - member this.fail ex id ss = + member this.fail ex id ss url = Console.ForegroundColor <- ConsoleColor.Red Console.WriteLine("Error: "); Console.ResetColor() Console.WriteLine(ex.Message); + Console.Write("Url: "); + Console.WriteLine(url); Console.WriteLine("Stack: "); ex.StackTrace.Split([| "\r\n"; "\n" |], StringSplitOptions.None) |> Array.iter (fun trace -> @@ -119,7 +121,7 @@ type TeamCityReporter() = interface IReporter with member this.pass () = consoleReporter.pass () - member this.fail ex id ss = + member this.fail ex id ss url = let mutable image = "" if not (Array.isEmpty ss) then image <- String.Format("canopy-image({0})", Convert.ToBase64String(ss)) @@ -128,7 +130,7 @@ type TeamCityReporter() = (tcFriendlyMessage id) (tcFriendlyMessage ex.Message) (tcFriendlyMessage image)) - consoleReporter.fail ex id ss + consoleReporter.fail ex id ss url member this.describe d = teamcityReport (sprintf "message text='%s' status='NORMAL'" (tcFriendlyMessage d)) @@ -207,7 +209,7 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string) = with get () = _browser member val reportPath = None with get, set - member val reportTemplateUrl = @"http://lefthandedgoat.github.com/canopy/reporttemplate.html" with get, set + member val reportTemplateUrl = @"file:///C:/projects/canopy/docs/files/reporttemplate.html" with get, set member this.js script = (_browser :?> IJavaScriptExecutor).ExecuteScript(script) member this.reportHtml () = (this.js "return $('*').html();").ToString() member private this.swallowedJS script = try (_browser :?> IJavaScriptExecutor).ExecuteScript(script) |> ignore with | ex -> () @@ -222,9 +224,13 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string) = this.swallowedJS (sprintf "addToContext('%s', 'Pass', '%s', '%s');" context test "") consoleReporter.pass () - member this.fail ex id ss = + member this.fail ex id ss url = this.swallowedJS (sprintf "addToContext('%s', 'Fail', '%s', '%s');" context test (Convert.ToBase64String(ss))) - consoleReporter.fail ex id ss + let stack = sprintf "%s%s%s" ex.Message System.Environment.NewLine ex.StackTrace + let stack = System.Web.HttpUtility.JavaScriptStringEncode(stack) + this.swallowedJS (sprintf "addStackToTest ('%s', '%s');" context stack) + this.swallowedJS (sprintf "addUrlToTest ('%s', '%s');" context url) + consoleReporter.fail ex id ss url member this.describe d = consoleReporter.describe d diff --git a/src/canopy/runner.fs b/src/canopy/runner.fs index 1910da83..ac5736ce 100644 --- a/src/canopy/runner.fs +++ b/src/canopy/runner.fs @@ -78,7 +78,7 @@ let fail (ex : Exception) id = let failSuite (ex: Exception) (suite : suite) = let reportFailedTest (ex: Exception) (test : Test) = reporter.testStart test.Id - fail ex test.Id + fail ex test.Id browser.Url reporter.testEnd test.Id suite.Tests |> List.iter (fun test -> reportFailedTest ex test) @@ -104,7 +104,7 @@ let run () = pass() with | ex when failureMessage <> null && failureMessage = ex.Message -> pass() - | ex -> fail ex test.Id + | ex -> fail ex test.Id browser.Url reporter.testEnd test.Id failureMessage <- null diff --git a/src/sampleprojectstructure/packages.config b/src/sampleprojectstructure/packages.config index 812c66b5..80c3fa88 100644 --- a/src/sampleprojectstructure/packages.config +++ b/src/sampleprojectstructure/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/sampleprojectstructure/sampleprojectstructure.fsproj b/src/sampleprojectstructure/sampleprojectstructure.fsproj index f99bcf90..28c12f11 100644 --- a/src/sampleprojectstructure/sampleprojectstructure.fsproj +++ b/src/sampleprojectstructure/sampleprojectstructure.fsproj @@ -51,7 +51,11 @@ - ..\..\packages\Selenium.WebDriver.2.45.0\lib\net40\WebDriver.dll + ..\..\packages\Selenium.WebDriver.2.46.0\lib\net40\WebDriver.dll + True + + + ..\..\packages\Selenium.Support.2.46.0\lib\net40\WebDriver.Support.dll True diff --git a/tests/basictests/basictests.fsproj b/tests/basictests/basictests.fsproj index d35beac9..2bf23798 100644 --- a/tests/basictests/basictests.fsproj +++ b/tests/basictests/basictests.fsproj @@ -75,11 +75,11 @@ - ..\..\packages\Selenium.WebDriver.2.45.0\lib\net40\WebDriver.dll + ..\..\packages\Selenium.WebDriver.2.46.0\lib\net40\WebDriver.dll True - ..\..\packages\Selenium.Support.2.45.0\lib\net40\WebDriver.Support.dll + ..\..\packages\Selenium.Support.2.46.0\lib\net40\WebDriver.Support.dll True diff --git a/tests/basictests/packages.config b/tests/basictests/packages.config index a1940c37..9ec92b84 100644 --- a/tests/basictests/packages.config +++ b/tests/basictests/packages.config @@ -2,6 +2,6 @@ - - + + \ No newline at end of file diff --git a/tests/documentationtests/documentationtests.fsproj b/tests/documentationtests/documentationtests.fsproj index 553b045e..2306c516 100644 --- a/tests/documentationtests/documentationtests.fsproj +++ b/tests/documentationtests/documentationtests.fsproj @@ -74,11 +74,11 @@ - ..\..\packages\Selenium.WebDriver.2.44.0\lib\net40\WebDriver.dll + ..\..\packages\Selenium.WebDriver.2.46.0\lib\net40\WebDriver.dll True - ..\..\packages\Selenium.Support.2.44.0\lib\net40\WebDriver.Support.dll + ..\..\packages\Selenium.Support.2.46.0\lib\net40\WebDriver.Support.dll True diff --git a/tests/documentationtests/packages.config b/tests/documentationtests/packages.config index 9561ab30..02a4c790 100644 --- a/tests/documentationtests/packages.config +++ b/tests/documentationtests/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file