From cd62900878c6f5fe42f1f323f0aea79dd3a17fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 12 Apr 2018 09:39:44 +0200 Subject: [PATCH] [IMP] web: add fail fast feature to qunit test suite With this commit, we introduce a new 'fail fast' feature to our qunit test suite: when it is activated, the qunit test suite will immediately stop after the first failed test. It is accessible as a flag in the url (failfast), or by clicking the checkbox in the UI. It is currently not activated by default. Note that this commit also change the url for the runbot phantomjs test in order to activate this feature. This allows us to increase the global timeout for the js test suite without fear! Backport of 611c836a4633 --- .../web/static/tests/helpers/qunit_config.js | 21 +++++++++++++++++++ addons/web/tests/test_js.py | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/addons/web/static/tests/helpers/qunit_config.js b/addons/web/static/tests/helpers/qunit_config.js index 8d2b287ab88..1fb99da4e43 100644 --- a/addons/web/static/tests/helpers/qunit_config.js +++ b/addons/web/static/tests/helpers/qunit_config.js @@ -130,4 +130,25 @@ function _addSortButton() { }); } +/** + * We add here a 'fail fast' feature: we often want to stop the test suite after + * the first failed test. This is also useful for the runbot test suites. + */ + +QUnit.config.urlConfig.push({ + id: "failfast", + label: "Fail Fast", + tooltip: "Stop the test suite immediately after the first failed test." +}); + +QUnit.begin(function() { + if (QUnit.config.failfast) { + QUnit.testDone(function(details) { + if (details.failed > 0) { + QUnit.config.queue.length = 0; + } + }); + } +}); + })(); diff --git a/addons/web/tests/test_js.py b/addons/web/tests/test_js.py index 62bc73d67d6..5d0f961fe59 100644 --- a/addons/web/tests/test_js.py +++ b/addons/web/tests/test_js.py @@ -13,11 +13,11 @@ class WebSuite(odoo.tests.HttpCase): def test_01_js(self): # webclient desktop test suite - self.phantom_js('/web/tests?mod=web', "", "", login='admin', timeout=390) + self.phantom_js('/web/tests?mod=web&failfast', "", "", login='admin', timeout=1800) def test_02_js(self): # webclient mobile test suite - self.phantom_js('/web/tests/mobile?mod=web', "", "", login='admin', timeout=300) + self.phantom_js('/web/tests/mobile?mod=web&failfast', "", "", login='admin', timeout=1800) def test_check_suite(self): # verify no js test is using `QUnit.only` as it forbid any other test to be executed