Skip to content

Commit

Permalink
fixed #112: Current suite is still run if AbortExecutionException thrown
Browse files Browse the repository at this point in the history
  • Loading branch information
S1artie committed Jun 20, 2016
1 parent e26f656 commit 1608ee6
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,14 @@ protected SuiteSummaryResult callSuiteSingle(Suite aSuiteCall) {
}

long tempSuiteDuration = System.nanoTime();
Map<SuiteStatementWithResult, List<? extends Result>> tempResults = executeSuite(aSuiteCall.getDefinition());
Map<SuiteStatementWithResult, List<? extends Result>> 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -930,15 +937,21 @@ protected List<SuiteDefinition> 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();
currentCallback.onSetupFinish(tempSetupSuite, tempSetupResult);
currentCallback.onCallbackProcessingEnd();
}
}

if (checkForAbortion()) {
break;
}
}

return tempSetupSuitesExecuted;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<integrity name="Integrity JUnit Testing" timestamp="20.06.16 10:37" isotimestamp="2016-06-20T10:37:41" duration="20.596" abortMessage="This is an abort exception in a call">
<variables />
<suite id="0" name="integrity.basic.exceptions.abortExceptions.abortDependentSuite" timestamp="20.06.16 10:37:41.0534">
<setup />
<variables />
<statements>
<suite id="1" line="97" name="integrity.basic.exceptions.abortExceptions.abortDependentSuiteDependingSuite" timestamp="20.06.16 10:37:41.0534">
<setup>
<suite id="2" line="104" name="integrity.basic.exceptions.abortExceptions.abortDependentSuiteRequiredSuite1" timestamp="20.06.16 10:37:41.0534">
<setup />
<variables />
<statements>
<call id="3" line="105" name="noOp" description="Do absolutely nothing." fixture="de.gebit.integrity.tests.fixtures.basic.NoOpFixture#noOp" timestamp="20.06.16 10:37:41.0550">
<parameters />
<result duration="0.839" type="success" />
</call>
<call id="4" line="106" name="throwAbortException" description="Throws an abortion exception" fixture="de.gebit.integrity.tests.fixtures.basic.NoOpFixture#throwAbortException" timestamp="20.06.16 10:37:41.0550">
<parameters>
<parameter name="message" value="This is an abort exception in a call" />
</parameters>
<result duration="1.631" type="exception" exceptionMessage="This is an abort exception in a call" exceptionTrace="de.gebit.integrity.exceptions.AbortExecutionException: This is an abort exception in a call&#xD;&#xA;&#x9;at de.gebit.integrity.tests.fixtures.basic.NoOpFixture.throwAbortException(NoOpFixture.java:202)&#xD;&#xA;&#x9;at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&#xD;&#xA;&#x9;at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)&#xD;&#xA;&#x9;at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)&#xD;&#xA;&#x9;at java.lang.reflect.Method.invoke(Method.java:606)&#xD;&#xA;&#x9;at de.gebit.integrity.fixtures.FixtureWrapper.execute(FixtureWrapper.java:313)&#xD;&#xA;&#x9;at de.gebit.integrity.runner.DefaultTestRunner.executeCallSingle(DefaultTestRunner.java:1743)&#xD;&#xA;&#x9;at de.gebit.integrity.runner.DefaultTestRunner.executeCall(DefaultTestRunner.java:1686)&#xD;&#xA;&#x9;at de.gebit.integrity.runner.DefaultTestRunner.executeSuite(DefaultTestRunner.java:1040)&#xD;&#xA;&#x9;at de.gebit.integrity.runner.DefaultTestRunner.executeSetupSuites(DefaultTestRunner.java:935)&#xD;&#xA;&#x9;at de.gebit.integrity.runner.DefaultTestRunner.callSuiteSingle(DefaultTestRunner.java:768)&#xD;&#xA;&#x9;at de.gebit.integrity.runner.DefaultTestRunner.callSuite(DefaultTestRunner.java:682)&#xD;&#xA;&#x9;at de.gebit.integrity.runner.DefaultTestRunner.executeSuite(DefaultTestRunner.java:1028)&#xD;&#xA;&#x9;at de.gebit.integrity.runner.DefaultTestRunner.callSuiteSingle(DefaultTestRunner.java:809)&#xD;&#xA;&#x9;at de.gebit.integrity.runner.DefaultTestRunner.runInternal(DefaultTestRunner.java:635)&#xD;&#xA;&#x9;at de.gebit.integrity.runner.DefaultTestRunner.run(DefaultTestRunner.java:513)&#xD;&#xA;&#x9;at de.gebit.integrity.runner.DefaultTestRunner.run(DefaultTestRunner.java:448)&#xD;&#xA;&#x9;at de.gebit.integrity.tests.junit.IntegrityJUnitTest.executeIntegritySuite(IntegrityJUnitTest.java:99)&#xD;&#xA;&#x9;at de.gebit.integrity.tests.junit.basic.exceptions.AbortExceptions.abortDependentSuite(AbortExceptions.java:172)&#xD;&#xA;&#x9;at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&#xD;&#xA;&#x9;at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)&#xD;&#xA;&#x9;at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)&#xD;&#xA;&#x9;at java.lang.reflect.Method.invoke(Method.java:606)&#xD;&#xA;&#x9;at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)&#xD;&#xA;&#x9;at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)&#xD;&#xA;&#x9;at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)&#xD;&#xA;&#x9;at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)&#xD;&#xA;&#x9;at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)&#xD;&#xA;&#x9;at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)&#xD;&#xA;&#x9;at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)&#xD;&#xA;&#x9;at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)&#xD;&#xA;&#x9;at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)&#xD;&#xA;&#x9;at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)&#xD;&#xA;&#x9;at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)&#xD;&#xA;&#x9;at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)&#xD;&#xA;&#x9;at org.junit.runners.ParentRunner.run(ParentRunner.java:363)&#xD;&#xA;&#x9;at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)&#xD;&#xA;&#x9;at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)&#xD;&#xA;&#x9;at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)&#xD;&#xA;&#x9;at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)&#xD;&#xA;&#x9;at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)&#xD;&#xA;&#x9;at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)&#xD;&#xA;" />
</call>
</statements>
<result duration="14.034" successCount="0" failureCount="0" exceptionCount="1" testExceptionCount="0" callExceptionCount="1" />
</suite>
</setup>
<variables />
<statements />
<returns />
<teardown />
<result duration="0.001" successCount="0" failureCount="0" exceptionCount="1" testExceptionCount="0" callExceptionCount="1" />
</suite>
</statements>
<returns />
<teardown />
<result duration="15.538" successCount="0" failureCount="0" exceptionCount="1" testExceptionCount="0" callExceptionCount="1" />
</suite>
</integrity>

0 comments on commit 1608ee6

Please sign in to comment.