fail the junit test if there were any failed test cases
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
5b9db15018
commit
b2979173c5
|
@ -109,6 +109,7 @@ public class AutobahnTests
|
||||||
List<AutobahnCaseResult> results = parseResults(Paths.get("target/reports/clients/index.json"));
|
List<AutobahnCaseResult> results = parseResults(Paths.get("target/reports/clients/index.json"));
|
||||||
String className = getClass().getName();
|
String className = getClass().getName();
|
||||||
writeJUnitXmlReport(results, "autobahn-client", className + ".client");
|
writeJUnitXmlReport(results, "autobahn-client", className + ".client");
|
||||||
|
throwIfFailed(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -139,6 +140,20 @@ public class AutobahnTests
|
||||||
List<AutobahnCaseResult> results = parseResults(Paths.get("target/reports/servers/index.json"));
|
List<AutobahnCaseResult> results = parseResults(Paths.get("target/reports/servers/index.json"));
|
||||||
String className = getClass().getName();
|
String className = getClass().getName();
|
||||||
writeJUnitXmlReport(results, "autobahn-server", className + ".server");
|
writeJUnitXmlReport(results, "autobahn-server", className + ".server");
|
||||||
|
throwIfFailed(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void throwIfFailed(List<AutobahnCaseResult> results) throws Exception
|
||||||
|
{
|
||||||
|
StringBuilder message = new StringBuilder();
|
||||||
|
for (AutobahnCaseResult result : results)
|
||||||
|
{
|
||||||
|
if (result.failed())
|
||||||
|
message.append(result.caseName).append(", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.length() > 0)
|
||||||
|
throw new Exception("Failed Test Cases: " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FileSignalWaitStrategy extends StartupCheckStrategy
|
private static class FileSignalWaitStrategy extends StartupCheckStrategy
|
||||||
|
@ -232,21 +247,11 @@ public class AutobahnTests
|
||||||
suiteDuration += duration;
|
suiteDuration += duration;
|
||||||
testcase.setAttribute("time", Double.toString(duration / 1000.0));
|
testcase.setAttribute("time", Double.toString(duration / 1000.0));
|
||||||
|
|
||||||
// failOnNonStrict option ?
|
if (r.failed())
|
||||||
switch (r.behavior())
|
|
||||||
{
|
{
|
||||||
case OK:
|
addFailure(testcase,r);
|
||||||
case INFORMATIONAL:
|
failures++;
|
||||||
case UNIMPLEMENTED:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NON_STRICT:
|
|
||||||
default:
|
|
||||||
addFailure(testcase,r);
|
|
||||||
failures++;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
root.addChild(testcase);
|
root.addChild(testcase);
|
||||||
}
|
}
|
||||||
root.setAttribute("failures", Integer.toString(failures));
|
root.setAttribute("failures", Integer.toString(failures));
|
||||||
|
@ -390,6 +395,21 @@ public class AutobahnTests
|
||||||
return behavior;
|
return behavior;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean failed()
|
||||||
|
{
|
||||||
|
switch (behavior)
|
||||||
|
{
|
||||||
|
case OK:
|
||||||
|
case INFORMATIONAL:
|
||||||
|
case UNIMPLEMENTED:
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case NON_STRICT:
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Behavior behaviorClose()
|
public Behavior behaviorClose()
|
||||||
{
|
{
|
||||||
return behaviorClose;
|
return behaviorClose;
|
||||||
|
|
Loading…
Reference in New Issue