diff --git a/extra/Junit4RunListener.jar b/extra/Junit4RunListener.jar index 7f2f7536..4e585066 100644 Binary files a/extra/Junit4RunListener.jar and b/extra/Junit4RunListener.jar differ diff --git a/extra/Junit5RunListener.jar b/extra/Junit5RunListener.jar index d3a76c71..c219be55 100644 Binary files a/extra/Junit5RunListener.jar and b/extra/Junit5RunListener.jar differ diff --git a/src/VERSION.py b/src/VERSION.py index c299f8d6..4ce7e541 100644 --- a/src/VERSION.py +++ b/src/VERSION.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -version = "Version 4.3.1 | 20200225" +version = "Version 4.3.2 | 20200225" diff --git a/src/checker/scripts/junit.policy b/src/checker/scripts/junit.policy index 0094385b..25a8e86a 100755 --- a/src/checker/scripts/junit.policy +++ b/src/checker/scripts/junit.policy @@ -1,8 +1,4 @@ grant { - // JUnit5 - permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; - permission java.lang.RuntimePermission "accessClassInPackage.sun.reflect"; - permission java.util.PropertyPermission "user.home","read"; permission java.io.FilePermission "/home/praktomat/junit.properties", "read"; permission java.io.FilePermission "/home/tester/junit.properties", "read"; @@ -17,4 +13,8 @@ grant { permission java.io.FilePermission "save.csv", "write"; permission java.io.FilePermission "spielDieZombie.txt", "write"; permission java.io.FilePermission "spielDieZombie2.txt", "write"; + + // JUnit5... + permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.reflect"; }; diff --git a/src/proforma/Java/Junit4ProFormAListener.java b/src/proforma/Java/Junit4ProFormAListener.java index 87fa554f..38f986e3 100644 --- a/src/proforma/Java/Junit4ProFormAListener.java +++ b/src/proforma/Java/Junit4ProFormAListener.java @@ -38,6 +38,7 @@ String value(); } + public class Junit4ProFormAListener extends RunListener { @@ -57,6 +58,8 @@ public class Junit4ProFormAListener extends RunListener { Element feedbackList; Element studentFeedback; + private boolean failureOutsideTest = false; + public Junit4ProFormAListener() { writer = System.out; @@ -117,6 +120,12 @@ public void testRunFinished(Result result) { e1.printStackTrace(); } + + if (this.failureOutsideTest) { + // no xml creation + return; + } + // Transform Document to XML String TransformerFactory tf = TransformerFactory.newInstance(); @@ -316,6 +325,7 @@ public void testFailure(Failure failure) { //Throwable cause1 = exception.getCause(); String exceptionText = exception.toString(); // name of exception + boolean showStackTraceToStudent = true; StackTraceElement[] strippedStacktrace = this.stripStackTrace(failure.getException().getStackTrace()); @@ -325,6 +335,14 @@ public void testFailure(Failure failure) { } stackTraceString = stackTraceString + "[...]\n"; + if (studentFeedback == null) { + this.failureOutsideTest = true; + writer.println(failure); + writer.println(""); + writer.println(stackTraceString); + return; + } + if (strippedStacktrace.length > 0) { if (strippedStacktrace[0].getClassName().startsWith("org.junit.")) { // Function Error in Test Code @@ -489,6 +507,9 @@ public static void main(String[] args) { System.exit(1); } + if (listener.failureOutsideTest) + System.exit(1); + System.exit(0); } } diff --git a/src/proforma/Java/Junit5ProFormAListener.java b/src/proforma/Java/Junit5ProFormAListener.java index 7a857968..0c8ee10e 100644 --- a/src/proforma/Java/Junit5ProFormAListener.java +++ b/src/proforma/Java/Junit5ProFormAListener.java @@ -55,6 +55,8 @@ public class Junit5ProFormAListener implements TestExecutionListener { private Exception exception = null; + private boolean failureOutsideTest = false; + public void executionStarted(TestIdentifier testIdentifier) { if (testIdentifier.getType() == Type.CONTAINER) @@ -110,8 +112,12 @@ public void executionStarted(TestIdentifier testIdentifier) { public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) { - if (testIdentifier.getType() == Type.CONTAINER) + if (testIdentifier.getType() == Type.CONTAINER) { + if (studentFeedback == null) { + testFailure(testExecutionResult); + } return; + } // writer.append("executionFinished: " + testIdentifier.getDisplayName()+ ": " + testExecutionResult + "\n"); // todo: bei failed noch den Fehlertext @@ -195,6 +201,11 @@ public void testPlanExecutionFinished(TestPlan testPlan){ e1.printStackTrace(); } + + if (this.failureOutsideTest) { + // no xml creation + return; + } // Transform Document to XML String TransformerFactory tf = TransformerFactory.newInstance(); @@ -267,6 +278,14 @@ private void testFailure(TestExecutionResult testExecutionResult) { } stackTraceString = stackTraceString + "[...]\n"; + if (studentFeedback == null) { + this.failureOutsideTest = true; + writer.println(exceptionText); + writer.println(""); + writer.println(stackTraceString); + return; + } + if (strippedStacktrace.length > 0) { if (strippedStacktrace[0].getClassName().startsWith("org.junit.")) { // Function Error in Test Code @@ -390,6 +409,8 @@ public static void main(String[] args) { System.err.println(listener.exception.getMessage()); System.exit(1); } + if (listener.failureOutsideTest) + System.exit(1); } catch (Exception e) { // reset redirection System.setOut(originalOut); @@ -399,6 +420,7 @@ public static void main(String[] args) { System.exit(1); } + System.exit(0); }