testng: NPE if setUp throws exception

This commit is contained in:
anna
2010-08-09 18:54:35 +04:00
parent 620efb5404
commit 3b8170b617
2 changed files with 22 additions and 13 deletions
@@ -109,19 +109,20 @@ public class TestNGConsoleView extends BaseTestsOutputConsoleView {
if (testNGResults != null) {
int exceptionMark = myExceptionalMark == -1 ? 0 : myExceptionalMark;
final String stackTrace = result.getStackTrace();
if (stackTrace != null && stackTrace.length() > 10) {
exceptionMark = currentTest.getCurrentSize();
//trim useless crud from stacktrace
String trimmed = trimStackTrace(stackTrace);
List<Printable> printables = getPrintables(result, trimmed);
for (Printable printable : printables) {
currentTest.addLast(printable);
if (currentTest != null) {
final String stackTrace = result.getStackTrace();
if (stackTrace != null && stackTrace.length() > 10) {
exceptionMark = currentTest.getCurrentSize();
//trim useless crud from stacktrace
List<Printable> printables = getPrintables(result);
for (Printable printable : printables) {
currentTest.addLast(printable);
}
}
final TestProxy failedToStart = testNGResults.getFailedToStart();
if (failedToStart != null) {
currentTest.addChild(failedToStart);
}
}
final TestProxy failedToStart = testNGResults.getFailedToStart();
if (failedToStart != null) {
currentTest.addChild(failedToStart);
}
testNGResults.addTestResult(result, exceptionMark);
myExceptionalMark = -1;
@@ -166,7 +167,8 @@ public class TestNGConsoleView extends BaseTestsOutputConsoleView {
return builder.toString();
}
private List<Printable> getPrintables(final TestResultMessage result, String s) {
static List<Printable> getPrintables(final TestResultMessage result) {
String s = trimStackTrace(result.getStackTrace());
List<Printable> printables = new ArrayList<Printable>();
//figure out if we have a diff we need to hyperlink
Matcher matcher = COMPARISION_PATTERN.matcher(s);
@@ -241,6 +241,13 @@ public class TestNGResults extends TestResultsPanel implements TestFrameworkRunn
else {
//do not remember testresultmessage: test hierarchy is not set
testCase = new TestProxy(result.toDisplayString());
final String stackTrace = result.getStackTrace();
if (stackTrace != null) {
final List<Printable> printables = TestNGConsoleView.getPrintables(result);
for (Printable printable : printables) {
testCase.addLast(printable);
}
}
failedToStart = testCase;
}