From 1608ee6abb56cdc4322a76558234441894ad2d8d Mon Sep 17 00:00:00 2001 From: Rene Schneider Date: Mon, 20 Jun 2016 11:39:22 +0200 Subject: [PATCH] fixed #112: Current suite is still run if AbortExecutionException thrown --- .../integrity/runner/DefaultTestRunner.java | 31 +++++++++----- .../exceptions/abortExceptions.integrity | 31 ++++++++++++++ .../basic/exceptions/AbortExceptions.java | 19 ++++++++- ...ns.abortExceptions.abortDependentSuite.xml | 40 +++++++++++++++++++ 4 files changed, 110 insertions(+), 11 deletions(-) create mode 100644 de.gebit.integrity.tests/results/integrity.basic.exceptions.abortExceptions.abortDependentSuite.xml diff --git a/de.gebit.integrity.runner/src/de/gebit/integrity/runner/DefaultTestRunner.java b/de.gebit.integrity.runner/src/de/gebit/integrity/runner/DefaultTestRunner.java index 603778531..b4a1ac2b3 100644 --- a/de.gebit.integrity.runner/src/de/gebit/integrity/runner/DefaultTestRunner.java +++ b/de.gebit.integrity.runner/src/de/gebit/integrity/runner/DefaultTestRunner.java @@ -802,7 +802,14 @@ protected SuiteSummaryResult callSuiteSingle(Suite aSuiteCall) { } long tempSuiteDuration = System.nanoTime(); - Map> tempResults = executeSuite(aSuiteCall.getDefinition()); + Map> tempResults; + // It is possible that a setup suite caused an abortion. If that's the case, use an empty suite result. + // Fixes issue #112. + if (!checkForAbortion()) { + tempResults = executeSuite(aSuiteCall.getDefinition()); + } else { + tempResults = new HashMap<>(); + } tempSuiteDuration = System.nanoTime() - tempSuiteDuration; // Fetch all output values into their respective local target variables @@ -866,12 +873,12 @@ protected SuiteSummaryResult callSuiteSingle(Suite aSuiteCall) { tempResult = new SuiteSummaryResult(tempForkResultSummary.getSuccessCount(), tempForkResultSummary.getFailureCount(), tempForkResultSummary.getTestExceptionCount(), tempForkResultSummary.getCallExceptionCount(), tempSuiteDuration); - } else { - if (tempFork != null && tempFork.hasAborted()) { - // If this happens, an abortion has happened on the fork due to an AbortExecutionException. - // TODO make this nicer, it's kind of ugly to create a fake object with null values - abortExecutionCause = new AbortExecutionCauseWrapper(null, null); - } + } + + if (tempFork != null && tempFork.hasAborted()) { + // If this happens, an abortion has happened on the fork due to an AbortExecutionException. + // TODO make this nicer, it's kind of ugly to create a fake object with null values + abortExecutionCause = new AbortExecutionCauseWrapper(null, null); } // and afterwards we'll switch back to real test mode @@ -930,8 +937,10 @@ protected List executeSetupSuites(SuiteDefinition aSuite, : new SuiteResult(tempSuiteResults, null, null, System.nanoTime() - tempStart); aSetupResultMap.put(tempSetupSuite, tempSetupResult); - tempSetupsAlreadyRun.add(tempSetupSuite); - tempSetupSuitesExecuted.add(tempSetupSuite); + if (!checkForAbortion()) { + tempSetupsAlreadyRun.add(tempSetupSuite); + tempSetupSuitesExecuted.add(tempSetupSuite); + } if (currentCallback != null) { currentCallback.onCallbackProcessingStart(); @@ -939,6 +948,10 @@ protected List executeSetupSuites(SuiteDefinition aSuite, currentCallback.onCallbackProcessingEnd(); } } + + if (checkForAbortion()) { + break; + } } return tempSetupSuitesExecuted; diff --git a/de.gebit.integrity.tests/integrity/suites/basic/exceptions/abortExceptions.integrity b/de.gebit.integrity.tests/integrity/suites/basic/exceptions/abortExceptions.integrity index 030c07b6f..8390a0f3e 100644 --- a/de.gebit.integrity.tests/integrity/suites/basic/exceptions/abortExceptions.integrity +++ b/de.gebit.integrity.tests/integrity/suites/basic/exceptions/abortExceptions.integrity @@ -91,5 +91,36 @@ packagedef integrity.basic.exceptions.abortExceptions with call integrity.fixtures.basic.noop.throwAbortException message: "This is an abort exception in a call" call integrity.fixtures.basic.noop.noOp // this should not be executed anymore suiteend + + + suitedef abortDependentSuite with + suite abortDependentSuiteDependingSuite + suiteend + + suitedef abortDependentSuiteDependingSuite requires abortDependentSuiteRequiredSuite1 abortDependentSuiteRequiredSuite1 with + call integrity.fixtures.basic.noop.noOp // this should not be executed anymore + suiteend + + suitedef abortDependentSuiteRequiredSuite1 concludedby abortDependentSuiteConcludedBySuite2 with + call integrity.fixtures.basic.noop.noOp + call integrity.fixtures.basic.noop.throwAbortException message: "This is an abort exception in a call" + call integrity.fixtures.basic.noop.noOp // this should not be executed anymore + suiteend + + suitedef abortDependentSuiteRequiredSuite2 concludedby abortDependentSuiteConcludedBySuite2 with + call integrity.fixtures.basic.noop.noOp // this should not be executed at all, since suite1 aborted everything + suiteend + + suitedef abortDependentSuiteConcludedBySuite1 with + call integrity.fixtures.basic.noop.noOp // this should not be executed at all, since conclusion suites are currently not executed when aborts happened + suiteend + + suitedef abortDependentSuiteConcludedBySuite2 with + call integrity.fixtures.basic.noop.noOp // this should not be executed at all, since conclusion suites are currently not executed when aborts happened + suiteend + + + + packageend \ No newline at end of file diff --git a/de.gebit.integrity.tests/junit/de/gebit/integrity/tests/junit/basic/exceptions/AbortExceptions.java b/de.gebit.integrity.tests/junit/de/gebit/integrity/tests/junit/basic/exceptions/AbortExceptions.java index 6a9f96a91..eb6af2bfd 100644 --- a/de.gebit.integrity.tests/junit/de/gebit/integrity/tests/junit/basic/exceptions/AbortExceptions.java +++ b/de.gebit.integrity.tests/junit/de/gebit/integrity/tests/junit/basic/exceptions/AbortExceptions.java @@ -107,8 +107,8 @@ public void abortExceptionInTableTestNested() throws ModelLoadException, IOExcep * @throws JDOMException */ @Test - public void abortExceptionInTableTestNestedWithMoreStuffBehind() throws ModelLoadException, IOException, - JDOMException { + public void abortExceptionInTableTestNestedWithMoreStuffBehind() + throws ModelLoadException, IOException, JDOMException { Document tempResult = executeIntegritySuite( new String[] { "integrity/suites/basic/exceptions/abortExceptions.integrity" }, "integrity.basic.exceptions.abortExceptions.abortExceptionInTableTestNestedWithMoreStuffBehind", null); @@ -160,4 +160,19 @@ public void abortExceptionInCallNestedWithMoreStuffBehind() throws ModelLoadExce assertDocumentMatchesReference(tempResult); } + /** + * Performs a test. + * + * @throws ModelLoadException + * @throws IOException + * @throws JDOMException + */ + @Test + public void abortDependentSuite() throws ModelLoadException, IOException, JDOMException { + Document tempResult = executeIntegritySuite( + new String[] { "integrity/suites/basic/exceptions/abortExceptions.integrity" }, + "integrity.basic.exceptions.abortExceptions.abortDependentSuite", null); + assertDocumentMatchesReference(tempResult); + } + } diff --git a/de.gebit.integrity.tests/results/integrity.basic.exceptions.abortExceptions.abortDependentSuite.xml b/de.gebit.integrity.tests/results/integrity.basic.exceptions.abortExceptions.abortDependentSuite.xml new file mode 100644 index 000000000..89726f1bf --- /dev/null +++ b/de.gebit.integrity.tests/results/integrity.basic.exceptions.abortExceptions.abortDependentSuite.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +