static Trouble constructTrouble(@NonNull String type, @NullAllowed String message, @NullAllowed String text, boolean error) { Trouble t = new Trouble(error); if (message != null) { Matcher match = COMPARISON_PATTERN.matcher(message); if (match.matches()) { t.setComparisonFailure(new Trouble.ComparisonFailure(match.group(1), match.group(2))); } else { match = COMPARISON_PATTERN_AFTER_65.matcher(message); if (match.matches()) { t.setComparisonFailure(new Trouble.ComparisonFailure(match.group(1), match.group(2))); } } } if (text != null) { String[] strs = StringUtils.split(text, "\n"); List<String> lines = new ArrayList<String>(); if (message != null) { lines.add(message); } lines.add(type); for (int i = 1; i < strs.length; i++) { lines.add(strs[i]); } t.setStackTrace(lines.toArray(new String[0])); } return t; }
return; testSession.getCurrentTestCase().setTrouble(new Trouble(shortMsg.equals(ADD_ERROR_PREFIX))); boolean hasErrMsg = (commaIndex != -1) && ((commaIndex + 2) <= insideBrackets.length()); // #166912
trouble = new Trouble(state == STATE_ERROR);
/** */ private boolean tryParseBriefHeader(String testcaseHeader) { final Matcher matcher = regexp.getTestcaseHeaderBriefPattern() .matcher(testcaseHeader); if (matcher.matches()) { String methodName = matcher.group(1); String clsName = matcher.group(2); boolean error = (matcher.group(3) == null); testcase = findTest(testSession.getCurrentSuite(), methodName); if (testcase == null){ // probably TestListener interface not reported test progress for some reason (for ex. debug mode) testcase = new JUnitTestcase(methodName, "JUnit test", testSession); testSession.addTestCase(testcase); } testcase.setClassName(clsName); Trouble trouble = testcase.getTrouble(); if (trouble == null){ trouble = new Trouble(error); testcase.setTrouble(trouble); }else{ trouble.setError(error); trouble.setStackTrace(null); } return true; } else { return false; } }
@Override public void setFailureInfo(String message, String[] stackTrace, boolean error, Diff diff) { Parameters.notNull("message", message); // NOI18N Parameters.notNull("stackTrace", stackTrace); // NOI18N Parameters.notNull("diff", diff); // NOI18N testSuite.checkFrozen(); Trouble trouble = new Trouble(error); trouble.setStackTrace(createStackTrace(message, stackTrace)); if (diff.isValid()) { Trouble.ComparisonFailure failure = new Trouble.ComparisonFailure(diff.getExpected(), diff.getActual()); trouble.setComparisonFailure(failure); } testCase.setTrouble(trouble); Manager manager = testSuite.getTestSession().getManager(); TestSession session = testSuite.getTestSession().getTestSession(); manager.displayOutput(session, getClassName() + "::" + testCase.getName() + "()", error); // NOI18N manager.displayOutput(session, message, error); testCase.addOutputLines(Collections.singletonList("<u>" + testCase.getName() + ":</u>")); // NOI18N for (String s : stackTrace) { manager.displayOutput(session, s, error); testCase.addOutputLines(Collections.singletonList(s.replace("<", "<"))); // NOI18N } manager.displayOutput(session, "", false); // NOI18N }