diff -r c16691cbb050 ruby.testrunner/src/org/netbeans/modules/ruby/testrunner/ui/Bundle.properties --- a/ruby.testrunner/src/org/netbeans/modules/ruby/testrunner/ui/Bundle.properties Mon Oct 06 16:59:47 2008 -0700 +++ b/ruby.testrunner/src/org/netbeans/modules/ruby/testrunner/ui/Bundle.properties Mon Oct 06 22:30:39 2008 -0700 @@ -96,6 +96,11 @@ MSG_TestMethodPending_HTML_time=PENDING ({0,number,0.0##} s) MSG_TestMethodError_HTML_time=caused an ERROR ({0,number,0.0##} s) +MSG_TestMethodPassed_HTML_cause=passed +MSG_TestMethodFailed_HTML_cause=FAILED ({0}) +MSG_TestMethodPending_HTML_cause=PENDING ({0}) +MSG_TestMethodError_HTML_cause=caused an ERROR ({0}) + # Elapsed time for a test suite MSG_TestSuiteElapsedTime= ({0,number,0.0##} s) diff -r c16691cbb050 ruby.testrunner/src/org/netbeans/modules/ruby/testrunner/ui/TestMethodNode.java --- a/ruby.testrunner/src/org/netbeans/modules/ruby/testrunner/ui/TestMethodNode.java Mon Oct 06 16:59:47 2008 -0700 +++ b/ruby.testrunner/src/org/netbeans/modules/ruby/testrunner/ui/TestMethodNode.java Mon Oct 06 22:30:39 2008 -0700 @@ -42,6 +42,7 @@ package org.netbeans.modules.ruby.testrunner.ui; import java.awt.Image; +import java.io.CharConversionException; import java.util.HashMap; import java.util.Map; import javax.swing.Action; @@ -51,12 +52,14 @@ import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; import org.openide.util.actions.SystemAction; +import org.openide.xml.XMLUtil; /** * * @author Marian Petras, Erno Mononen */ final class TestMethodNode extends AbstractNode { + private static final boolean INLINE_RESULTS = Boolean.getBoolean("junit.inline_result"); // NOI18N /** */ private final Report.Testcase testcase; @@ -119,6 +122,26 @@ buf.append("  "); //NOI18N buf.append(""); //NOI18N + + String cause = null; +// if (INLINE_RESULTS && testcase.trouble != null && testcase.trouble.message != null && +// !"null".equals(testcase.trouble.message)) { // NOI18N + if (INLINE_RESULTS && testcase.trouble != null && testcase.trouble.stackTrace != null && + testcase.trouble.stackTrace.length > 0) { + try { + //cause = XMLUtil.toElementContent(testcase.trouble.message); + cause = XMLUtil.toElementContent(testcase.trouble.stackTrace[0]); + } catch (CharConversionException ex) { + // We're messing with user testoutput - always risky. Don't complain + // here, simply fall back to the old behavior of the test runner - + // don't include the message + cause = null; + } + } + if (cause != null) { + buf.append(NbBundle.getMessage(getClass(), + DisplayNameMapper.getCauseKey(status), cause)); + } else buf.append(testcase.timeMillis < 0 ? NbBundle.getMessage(getClass(), DisplayNameMapper.getNoTimeKey(status)) @@ -211,6 +234,19 @@ result.put(Status.PENDING, "MSG_TestMethodPending_HTML_time"); //NOI18N return result; } + + private static final Map< Status,String> CAUSE_KEYS = initCauseKeys(); + private static Map< Status,String> initCauseKeys() { + Map< Status,String> result = new HashMap< Status,String>(4); + result.put(Status.PASSED, "MSG_TestMethodPassed_HTML_cause"); //NOI18N + result.put(Status.ERROR, "MSG_TestMethodError_HTML_cause"); //NOI18N + result.put(Status.FAILED, "MSG_TestMethodFailed_HTML_cause"); //NOI18N + result.put(Status.PENDING, "MSG_TestMethodPending_HTML_cause"); //NOI18N + return result; + } + static String getCauseKey(Status status) { + return CAUSE_KEYS.get(status); + } static String getNoTimeKey(Status status) { return NO_TIME_KEYS.get(status); @@ -219,6 +255,5 @@ static String getTimeKey(Status status) { return TIME_KEYS.get(status); } - } }