From ed40ee54524b8b8f9a30a32a08afc3ba493c54c9 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Fri, 3 Feb 2017 01:51:55 -0500 Subject: [PATCH] testing: extract `fail` method to make a test case fail without running it Signed-off-by: Alexandre Terrasa --- src/testing/testing_suite.nit | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/testing/testing_suite.nit b/src/testing/testing_suite.nit index e788067..a350210 100644 --- a/src/testing/testing_suite.nit +++ b/src/testing/testing_suite.nit @@ -138,10 +138,8 @@ class TestSuite compile if failure != null then for case in test_cases do - case.is_done = true - case.error = "Compilation Error" + case.fail "Compilation Error" case.raw_output = failure - toolcontext.modelbuilder.failed_tests += 1 toolcontext.clear_progress_bar toolcontext.show_unit(case) end @@ -318,6 +316,15 @@ class TestCase is_done = true end + # Make the test case fail without testing it + # + # Useful when the compilation or the before_test failed. + fun fail(message: String) do + is_done = true + error = message + toolcontext.modelbuilder.failed_tests += 1 + end + redef fun xml_classname do var a = test_method.full_name.split("$") return "nitunit.{a[0]}.{a[1]}" -- 1.7.9.5