Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Minor style tweaks. Make sure sample report is generated correctly wi…

…th latest TestNG.
  • Loading branch information...
commit 9461e5d1d401d4ecd22096b3196314dce342d311 1 parent 398471c
@dwdyer authored
View
15 README.txt
@@ -46,6 +46,10 @@ output:
If escaping is turned off then log text is included as raw HTML/XML,
which allows for the insertion of hyperlinks and other nasty hacks.
+ org.uncommons.reportng.failures-only
+ Defaults to "false". If set to "true" the HTML report will exclude tests
+ that completed without failures.
+
org.uncommons.reportng.frames
Defaults to "true". If set to "false" generates the HTML report without
using a frameset. No navigation page is generated and the overview page
@@ -76,6 +80,11 @@ output:
org.uncommons.reportng.title
Used to over-ride the report title.
+ org.uncommons.reportng.velocity-log
+ Since version 1.1.3, ReportNG will no longer generate a Velocity log file
+ by default. If you want a log file you should set this property to
+ "true".
+
org.uncommons.reportng.xml-dialect
Controls the XML generated by JUnitXMLReporter. If set to "testng" (the
default) then skipped tests appear as "skipped" in the XML. This is
@@ -83,9 +92,3 @@ output:
dialect of the XML format. Other tools, such as Ant's junitreport task,
do not have a notion of skipped tests. For these tools the dialect can
be set to "junit" and skipped tests will be marked as failures.
-
- org.uncommons.reportng.velocity-log
- Since version 1.1.3, ReportNG will no longer generate a Velocity log file
- by default. If you want a log file you should set this property to
- "true".
-
View
10 etc/intellij/reportng.ipr
@@ -273,6 +273,16 @@
<option name="ignoreNonEmtpyLoops" value="false" />
</inspection_tool>
<inspection_tool class="ZeroLengthArrayInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="groupsTestNG" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="groups">
+ <value>
+ <list size="2">
+ <item index="0" class="java.lang.String" itemvalue="should-fail" />
+ <item index="1" class="java.lang.String" itemvalue="should-skip" />
+ </list>
+ </value>
+ </option>
+ </inspection_tool>
</profile>
</profiles>
<option name="PROJECT_PROFILE" value="Project Default" />
View
5 etc/sample-testng.xml
@@ -9,9 +9,10 @@
</test>
<!-- Use the same tests again. -->
- <test name="Only Successful Tests" >
+ <test name="Only Unsuccessful Tests" >
<classes>
- <class name="org.uncommons.reportng.sample.SuccessfulTests" />
+ <class name="org.uncommons.reportng.sample.FailedTests" />
+ <class name="org.uncommons.reportng.sample.SkippedTests" />
</classes>
</test>
View
4 etc/sample2-testng.xml
@@ -3,9 +3,9 @@
<suite name="Another Suite" verbose="1" >
<!-- Use the same tests again. -->
- <test name="Only Skipped Tests" >
+ <test name="Only Successful Tests" >
<classes>
- <class name="org.uncommons.reportng.sample.SkippedTests" />
+ <class name="org.uncommons.reportng.sample.SuccessfulTests" />
</classes>
</test>
View
37 reportng/src/java/main/org/uncommons/reportng/HTMLReporter.java
@@ -48,7 +48,7 @@
public class HTMLReporter extends AbstractReporter
{
private static final String FRAMES_PROPERTY = "org.uncommons.reportng.frames";
- private static final String ONLY_FAILURES_PROPERTY = "org.uncommons.reportng.onlyreportfailures";
+ private static final String ONLY_FAILURES_PROPERTY = "org.uncommons.reportng.failures-only";
private static final String TEMPLATES_PATH = "org/uncommons/reportng/templates/html/";
private static final String INDEX_FILE = "index.html";
@@ -70,7 +70,7 @@
private static final String SKIPPED_TESTS_KEY = "skippedTests";
private static final String PASSED_TESTS_KEY = "passedTests";
private static final String METHODS_KEY = "methods";
- private static final String ONLY_FAILURES_KEY = "onlyreportfailures";
+ private static final String ONLY_FAILURES_KEY = "onlyReportFailures";
private static final String REPORT_DIRECTORY = "html";
@@ -114,7 +114,7 @@ public void generateReport(List<XmlSuite> xmlSuites,
createResults(suites, outputDirectory, onlyFailures);
// Chronology disabled until I figure out how to make it less nonsensical.
//createChronology(suites, outputDirectory);
- createLog(outputDirectory,onlyFailures);
+ createLog(outputDirectory, onlyFailures);
copyResources(outputDirectory);
}
catch (Exception ex)
@@ -182,25 +182,22 @@ private void createResults(List<ISuite> suites,
int index2 = 1;
for (ISuiteResult result : suite.getResults().values())
{
- boolean failuresExist = ((result.getTestContext().getFailedTests().size() > 0) || (result.getTestContext().getFailedConfigurations().size() > 0));
- if (onlyShowFailures && !failuresExist)
+ boolean failuresExist = result.getTestContext().getFailedTests().size() > 0
+ || result.getTestContext().getFailedConfigurations().size() > 0;
+ if (!onlyShowFailures || failuresExist)
{
- //onlyShowFailures is true and this result doesn't have any failed tests or configurations, so skip file creation
- ++index2; //increment the suite number because the velocity template will
- continue;
+ VelocityContext context = createContext();
+ context.put(RESULT_KEY, result);
+ context.put(FAILED_CONFIG_KEY, sortByTestClass(result.getTestContext().getFailedConfigurations()));
+ context.put(SKIPPED_CONFIG_KEY, sortByTestClass(result.getTestContext().getSkippedConfigurations()));
+ context.put(FAILED_TESTS_KEY, sortByTestClass(result.getTestContext().getFailedTests()));
+ context.put(SKIPPED_TESTS_KEY, sortByTestClass(result.getTestContext().getSkippedTests()));
+ context.put(PASSED_TESTS_KEY, sortByTestClass(result.getTestContext().getPassedTests()));
+ String fileName = String.format("suite%d_test%d_%s", index, index2, RESULTS_FILE);
+ generateFile(new File(outputDirectory, fileName),
+ RESULTS_FILE + TEMPLATE_EXTENSION,
+ context);
}
-
- VelocityContext context = createContext();
- context.put(RESULT_KEY, result);
- context.put(FAILED_CONFIG_KEY, sortByTestClass(result.getTestContext().getFailedConfigurations()));
- context.put(SKIPPED_CONFIG_KEY, sortByTestClass(result.getTestContext().getSkippedConfigurations()));
- context.put(FAILED_TESTS_KEY, sortByTestClass(result.getTestContext().getFailedTests()));
- context.put(SKIPPED_TESTS_KEY, sortByTestClass(result.getTestContext().getSkippedTests()));
- context.put(PASSED_TESTS_KEY, sortByTestClass(result.getTestContext().getPassedTests()));
- String fileName = String.format("suite%d_test%d_%s", index, index2, RESULTS_FILE);
- generateFile(new File(outputDirectory, fileName),
- RESULTS_FILE + TEMPLATE_EXTENSION,
- context);
++index2;
}
++index;
View
2  reportng/src/java/resources/org/uncommons/reportng/templates/html/overview.html.vm
@@ -65,7 +65,7 @@
#set ($totalFailed = $totalFailed + $result.testContext.failedTests.size())
#set ($failuresExist = $result.testContext.failedTests.size()>0 || $result.testContext.failedConfigurations.size()>0)
- #if (($onlyreportfailures && $failuresExist) || (!$onlyreportfailures))
+ #if (($onlyReportFailures && $failuresExist) || (!$onlyReportFailures))
<tr class="test">
<td class="test">
<a href="suite${suiteId}_test${velocityCount}_results.html">${result.testContext.name}</a>
View
2  reportng/src/java/resources/org/uncommons/reportng/templates/html/suites.html.vm
@@ -40,7 +40,7 @@
#foreach ($result in $suite.results)
#set ($failuresExist = $result.testContext.failedTests.size()>0 || $result.testContext.failedConfigurations.size()>0)
- #if (($onlyreportfailures && $failuresExist) || (!$onlyreportfailures))
+ #if (($onlyReportFailures && $failuresExist) || (!$onlyReportFailures))
<tr>
<td class="test">
#if ($result.testContext.failedTests.size() > 0)
View
1  reportng/src/java/test/org/uncommons/reportng/sample/SkippedTests.java
@@ -22,6 +22,7 @@
* another class.
* @author Daniel Dyer
*/
+@Test(groups = "should-skip")
public class SkippedTests
{
@Test(dependsOnGroups = "should-fail")
Please sign in to comment.
Something went wrong with that request. Please try again.