/** * Add an optional String element to the current tag. If value is null, nothing is * added. * @param tagName The name of the tag * @param value The value for this tag */ public void addOptional(String tagName, @Nullable String value) { addOptional(tagName, value, (Properties) null); }
/** * Add an optional Boolean element to the current tag. If value is null, nothing is * added. * @param tagName The name of the tag * @param value The value for this tag */ public void addOptional(String tagName, @Nullable Boolean value) { addOptional(tagName, value, null); }
/** * Add an optional Boolean element to the current tag. If value is null, nothing is added. * * @param tagName The name of the tag * @param value The value for this tag */ public void addOptional(String tagName, @Nullable Boolean value) { addOptional(tagName, value, null); }
/** * Add an optional String element to the current tag. If value is null, nothing is added. * * @param tagName The name of the tag * @param value The value for this tag */ public void addOptional(String tagName, @Nullable String value) { addOptional(tagName, value, (Properties) null); }
private void generateMethod(String tagClass, ITestResult tr, ITestContext context, XMLStringBuffer xsb) { long time = tr.getEndMillis() - tr.getStartMillis(); xsb.push(D, C, "method"); xsb.push(D, C, "method-content"); xsb.addOptional(S, tr.getMethod().getMethodName(), C, "method-name"); // Parameters? if (tr.getParameters().length > 0) { StringBuilder sb = new StringBuilder(); boolean first = true; for (Object p : tr.getParameters()) { if (!first) sb.append(", "); first = false; sb.append(Utils.toString(p)); } xsb.addOptional(S, "(" + sb.toString() + ")", C, "parameters"); } // Exception? if (tr.getThrowable() != null) { StringBuilder stackTrace = new StringBuilder(); for (StackTraceElement str : tr.getThrowable().getStackTrace()) { stackTrace.append(str.toString()).append("<br>"); } xsb.addOptional(D, stackTrace.toString() + "\n", C, "stack-trace"); } xsb.addOptional(S, " " + Long.toString(time) + " ms", C, "method-time"); xsb.pop(D); xsb.pop(D); }
private void addLinkTo(XMLStringBuffer header, INavigatorPanel panel, ISuite suite) { String text = panel.getNavigatorLink(suite); header.push("li"); header.push("a", "href", "#", "panel-name", panel.getPanelName(suite), C, "navigator-link "); String className = panel.getClassName(); if (className != null) { header.addOptional(S, text, C, className); } else { header.addOptional(S, text); } header.pop("a"); header.pop("li"); }
private void addLinkTo(XMLStringBuffer header, INavigatorPanel panel, ISuite suite) { String text = panel.getNavigatorLink(suite); header.push("li"); header.push("a", "href", "#", "panel-name", panel.getPanelName(suite), C, "navigator-link "); String className = panel.getClassName(); if (className != null) { header.addOptional(S, text, C, className); } else { header.addOptional(S, text); } header.pop("a"); header.pop("li"); }
xsb.push("a", "name", Model.getTestResultName(tr)); xsb.pop("a"); xsb.addOptional(S, tr.getMethod().getMethodName(), C, "method-name"); sb.append(Utils.toString(p)); xsb.addOptional(S, "(" + sb.toString() + ")", C, "parameters"); StringBuilder stackTrace = new StringBuilder(); stackTrace.append(Utils.shortStackTrace(tr.getThrowable(), true)); xsb.addOptional(D, stackTrace.toString() + "\n", C, "stack-trace");
@Test public void testMethod() { IBuffer result = Buffer.create(); XMLStringBuffer sb = new XMLStringBuffer(result, ""); sb.push("family"); Properties p = new Properties(); p.setProperty("prop1", "value1"); p.setProperty("prop2", "value2"); sb.addRequired("cedric", "true", p); sb.addRequired("alois", "true"); sb.addOptional("anne-marie", (String) null); sb.pop(); String expected = "<family>" + EOL + " <cedric prop2=\"value2\" prop1=\"value1\">true</cedric>" + EOL + " <alois>true</alois>" + EOL + "</family>"; assertThat(result.toString().trim()).isEqualTo(expected); }
xsb.push("a", "name", Model.getTestResultName(tr)); xsb.pop("a"); xsb.addOptional(S, tr.getMethod().getMethodName(), C, "method-name"); sb.append(Utils.toString(p)); xsb.addOptional(S, "(" + sb.toString() + ")", C, "parameters"); StringBuilder stackTrace = new StringBuilder(); stackTrace.append(Utils.shortStackTrace(tr.getThrowable(), true)); xsb.addOptional(D, stackTrace.toString() + "\n", C, "stack-trace");
private void generateClassPanel(Class c, List<ITestResult> results, XMLStringBuffer xsb, String status, ISuite suite) { xsb.push(D, C, "suite-" + suiteToTag(suite) + "-class-" + status); xsb.push(D, C, "main-panel-header rounded-window-top"); // Passed/failed icon xsb.addEmptyElement("img", "src", Model.getImage(status)); xsb.addOptional(S, c.getName(), C, "class-name"); xsb.pop(D); xsb.push(D, C, "main-panel-content rounded-window-bottom"); for (ITestResult tr : results) { generateMethod(tr, xsb); } xsb.pop(D); xsb.pop(D); }
private void generateClassPanel( Class c, List<ITestResult> results, XMLStringBuffer xsb, String status, ISuite suite) { xsb.push(D, C, "suite-" + suiteToTag(suite) + "-class-" + status); xsb.push(D, C, "main-panel-header rounded-window-top"); // Passed/failed icon xsb.addEmptyElement("img", "src", Model.getImage(status)); xsb.addOptional(S, c.getName(), C, "class-name"); xsb.pop(D); xsb.push(D, C, "main-panel-content rounded-window-bottom"); for (ITestResult tr : results) { generateMethod(tr, xsb); } xsb.pop(D); xsb.pop(D); }
generateTests("passed", context.getPassedTests(), context, xs3); xsb.addOptional(D, "Failed" + " tests", C, "result-banner " + "failed"); xsb.addString(xs1.toXML()); xsb.addOptional(D, "Skipped" + " tests", C, "result-banner " + "skipped"); xsb.addString(xs2.toXML()); xsb.addOptional(D, "Passed" + " tests", C, "result-banner " + "passed"); xsb.addString(xs3.toXML()); header.addOptional(S, suite.getName(), C, "suite-name"); header.push(D, C, "stats"); int total = failed + skipped + passed; header.addOptional(S, stats, C, "method-stats"); header.pop("li"); header.addOptional(S, String.format("%s ", pluralize(results.values().size(), "test"), C, "test-stats")); header.pop("li"); String testName = tr.getTestContext().getName(); header.push("li"); header.addOptional("a", testName, "href", "#" + m_testMap.get(testName)); header.pop("li");
@Override public void generate(XMLStringBuffer xsb) { for (ISuite s : getSuites()) { xsb.push(D, C, "panel", "panel-name", getPanelName(s)); xsb.push(D, C, "main-panel-header rounded-window-top"); xsb.addOptional(S, getHeader(s), C, "header-content"); xsb.pop(D); xsb.push(D, C, "main-panel-content rounded-window-bottom"); xsb.addString(getContent(s, xsb)); xsb.pop(D); xsb.pop(D); } }
@Override public void generate(XMLStringBuffer xsb) { for (ISuite s : getSuites()) { xsb.push(D, C, "panel", "panel-name", getPanelName(s)); xsb.push(D, C, "main-panel-header rounded-window-top"); xsb.addOptional(S, getHeader(s), C, "header-content"); xsb.pop(D); xsb.push(D, C, "main-panel-content rounded-window-bottom"); xsb.addString(getContent(s, xsb)); xsb.pop(D); xsb.pop(D); } }
private void generateResult(XMLStringBuffer header, int failed, int skipped, int passed, ISuite suite, String suiteName) { // // Results // header.push(D, C, "result-section"); header.push(D, C, "suite-section-title"); header.addRequired(S, "Results"); header.pop(D); // Method stats int total = failed + skipped + passed; String stats = String.format("%s, %s %s %s", pluralize(total, "method"), maybe(failed, "failed", ", "), maybe(skipped, "skipped", ", "), maybe(passed, "passed", "")); header.push(D, C, "suite-section-content"); header.push("ul"); header.push("li"); header.addOptional(S, stats, C, "method-stats"); header.pop("li"); generateMethodList("Failed methods", new ResultsByStatus(suite, "failed", ITestResult.FAILURE), suiteName, header); generateMethodList("Skipped methods", new ResultsByStatus(suite, "skipped", ITestResult.SKIP), suiteName, header); generateMethodList("Passed methods", new ResultsByStatus(suite, "passed", ITestResult.SUCCESS), suiteName, header); }
xsb.addOptional(S, c.getName(), C, "class-name");
header.push("ul"); header.push("li"); header.addOptional(S, stats, C, "method-stats"); header.pop("li");
"panel-name", suiteName, C, "navigator-link"); header.addOptional(S, suite.getName(), C, "suite-name border-" + getModel().getStatusForSuite(suite.getName())); header.pop("a");
header.addOptional( S, suite.getName(),