From 1a854192e5069b181b5cc8847b53481689156aad Mon Sep 17 00:00:00 2001 From: Alex Maitland Date: Thu, 14 Oct 2021 13:00:08 +1000 Subject: [PATCH] Test - Output QUnit results if tests failed --- .../JavascriptBinding/IntegrationTestFacts.cs | 26 ++++++++++++++----- CefSharp.Test/QUnitTestResult.cs | 19 ++++++++++++++ CefSharp.Test/WebBrowserTestExtensions.cs | 6 ++--- 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 CefSharp.Test/QUnitTestResult.cs diff --git a/CefSharp.Test/JavascriptBinding/IntegrationTestFacts.cs b/CefSharp.Test/JavascriptBinding/IntegrationTestFacts.cs index 87753d95b3..6517d2c77d 100644 --- a/CefSharp.Test/JavascriptBinding/IntegrationTestFacts.cs +++ b/CefSharp.Test/JavascriptBinding/IntegrationTestFacts.cs @@ -70,11 +70,18 @@ public async Task LoadJavaScriptBindingQunitTestsSuccessfulCompletion() repo.Register("boundAsync2", new AsyncBoundObject(), isAsync: true, options: bindingOptions); browser.CreateBrowser(); - var success = await browser.WaitForQUnitTestExeuctionToComplete(); + var response = await browser.WaitForQUnitTestExeuctionToComplete(); - Assert.True(success); + if (!response.Success) + { + output.WriteLine("QUnit Details : {0}", response.Details); + output.WriteLine("QUnit Passed : {0}", response.Total); + output.WriteLine("QUnit Total : {0}", response.Passed); + } - output.WriteLine("QUnit Tests result: {0}", success); + Assert.True(response.Success); + + output.WriteLine("QUnit Tests result: {0}", response.Success); } } @@ -92,11 +99,18 @@ public async Task LoadLegacyJavaScriptBindingQunitTestsSuccessfulCompletion() repo.Register("boundAsync", new AsyncBoundObject(), isAsync: true, options: bindingOptions); browser.CreateBrowser(); - var success = await browser.WaitForQUnitTestExeuctionToComplete(); + var response = await browser.WaitForQUnitTestExeuctionToComplete(); - Assert.True(success); + if(!response.Success) + { + output.WriteLine("QUnit Details : {0}", response.Details); + output.WriteLine("QUnit Passed : {0}", response.Total); + output.WriteLine("QUnit Total : {0}", response.Passed); + } - output.WriteLine("QUnit Tests result: {0}", success); + Assert.True(response.Success); + + output.WriteLine("QUnit Tests result: {0}", response.Success); } } #endif diff --git a/CefSharp.Test/QUnitTestResult.cs b/CefSharp.Test/QUnitTestResult.cs new file mode 100644 index 0000000000..d816b9491f --- /dev/null +++ b/CefSharp.Test/QUnitTestResult.cs @@ -0,0 +1,19 @@ +// Copyright © 2021 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + +namespace CefSharp.Test +{ + public class QUnitTestResult + { + public bool Success + { + get { return Passed == Total; } + } + + public int Passed { get; set; } + public int Total { get; set; } + + public string Details { get; set; } + } +} diff --git a/CefSharp.Test/WebBrowserTestExtensions.cs b/CefSharp.Test/WebBrowserTestExtensions.cs index ad2ccfcd5c..b54cf5f77d 100644 --- a/CefSharp.Test/WebBrowserTestExtensions.cs +++ b/CefSharp.Test/WebBrowserTestExtensions.cs @@ -76,11 +76,11 @@ public static Task LoadRequestAsync(this IWebBrowser brows return tcs.Task; } - public static Task WaitForQUnitTestExeuctionToComplete(this IWebBrowser browser) + public static Task WaitForQUnitTestExeuctionToComplete(this IWebBrowser browser) { //If using .Net 4.6 then use TaskCreationOptions.RunContinuationsAsynchronously //and switch to tcs.TrySetResult below - no need for the custom extension method - var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); EventHandler handler = null; handler = (sender, args) => @@ -95,7 +95,7 @@ public static Task WaitForQUnitTestExeuctionToComplete(this IWebBrowser br var total = (int)details.total; var passed = (int)details.passed; - tcs.TrySetResult(total == passed); + tcs.TrySetResult(new QUnitTestResult { Details = details, Passed = passed, Total = total }); } else {