From c4e075cf04f598d824469092b0043b3924c0fad0 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 30 Jan 2020 09:56:58 +0000 Subject: [PATCH] [IMP] core, web: test failure reporting * remove misleading documentation about a "test failed" message, in 13.0 any uncaught exception or console.error will cause the current test to be interpreted as failed * fix tour manager to console.error its step and not add a second useless error message * fix menu tester to try and display the failure cause on failure * improve qunit's test reporter to print the number of tests failed in case of test suite failure Should make test failures in tours a bit clearer. closes odoo/odoo#44296 X-original-commit: 78121b68d099b16f2d775a7a8a963a2a0f474843 Signed-off-by: Xavier Morel (xmo) --- addons/web/static/src/js/tools/test_menus.js | 7 +++---- addons/web/static/tests/helpers/qunit_config.js | 2 +- addons/web_tour/static/src/js/tour_manager.js | 1 - odoo/tests/common.py | 9 ++------- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/addons/web/static/src/js/tools/test_menus.js b/addons/web/static/src/js/tools/test_menus.js index 224df93a008..1875c0e776e 100644 --- a/addons/web/static/src/js/tools/test_menus.js +++ b/addons/web/static/src/js/tools/test_menus.js @@ -79,14 +79,13 @@ var testPromise = Promise.resolve(); testPromise = chainDeferred($listOfAppMenuItems, testPromise, testApp); return testPromise.then(function () { + console.log("Test took ", (performance.now() - startTime) / 1000, " seconds"); console.log("Successfully tested ", testedApps.length, " apps"); console.log("Successfully tested ", testedMenus.length - testedApps.length, " menus"); console.log("test successful"); + }).catch(function (error) { console.log("Test took ", (performance.now() - startTime) / 1000, " seconds"); - }).catch(function () { - console.log("Test took ", (performance.now() - startTime) / 1000, " seconds"); - console.error('test failed') - console.error("Error !"); + console.error(error || 'test failed'); }); } diff --git a/addons/web/static/tests/helpers/qunit_config.js b/addons/web/static/tests/helpers/qunit_config.js index 8308f972a47..664808c3cb1 100644 --- a/addons/web/static/tests/helpers/qunit_config.js +++ b/addons/web/static/tests/helpers/qunit_config.js @@ -50,7 +50,7 @@ QUnit.done(function(result) { if (!result.failed) { console.log('test successful'); } else { - console.error('test failed'); + console.error(result.failed, "/", result.total, "tests failed"); } if (!sortButtonAppended) { diff --git a/addons/web_tour/static/src/js/tour_manager.js b/addons/web_tour/static/src/js/tour_manager.js index cf95b3516c6..6e3ebff46e7 100644 --- a/addons/web_tour/static/src/js/tour_manager.js +++ b/addons/web_tour/static/src/js/tour_manager.js @@ -365,7 +365,6 @@ return core.Class.extend(mixins.EventDispatcherMixin, ServicesMixin, { }); console.log(document.body.parentElement.outerHTML); console.error(error); // will be displayed as error info - console.error("test failed"); // browser_js wait for error message "test failed" } else { console.log(_.str.sprintf("Tour %s succeeded", tour_name)); console.log("test successful"); // browser_js wait for message "test successful" diff --git a/odoo/tests/common.py b/odoo/tests/common.py index 456544ec513..a62aad3b41a 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -1251,13 +1251,8 @@ class HttpCase(TransactionCase): - wait for ready object to be available - eval(code) inside the page - To signal success test do: - console.log('test successful') - - To signal failure do: - console.error('test failed') - - If neither are done before timeout test fails. + To signal success test do: console.log('test successful') + To signal test failure raise an exception or call console.error """ # increase timeout if coverage is running if any(f.filename.endswith('/coverage/execfile.py') for f in inspect.stack() if f.filename):