Author: emuckenhuber
Date: 2007-10-18 06:10:11 -0400 (Thu, 18 Oct 2007)
New Revision: 8687
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/report/junit/JUnitReporterTests.java
modules/test/trunk/unit/src/main/org/jboss/unit/report/
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitReporter.java
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestReport.java
Log:
- generating testcase name based on TestInfo names
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/report/junit/JUnitReporterTests.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/test/unit/report/junit/JUnitReporterTests.java 2007-10-18
06:17:01 UTC (rev 8686)
+++
modules/test/trunk/unit/src/main/org/jboss/test/unit/report/junit/JUnitReporterTests.java 2007-10-18
10:10:11 UTC (rev 8687)
@@ -60,7 +60,7 @@
{
MyTestReport report = new MyTestReport(testSuiteName);
// add StartRunnerEvent
- report.startTestSuite(new StartRunnerEvent());
+ report.startJUnitTestSuite(new StartRunnerEvent());
// add RunnerFailureEvent
Failure f = new Failure("fehler", FailureType.ERROR);
RunnerFailureEvent rfe = new RunnerFailureEvent(f);
@@ -97,7 +97,7 @@
private static void testTestCase()
{
MyTestReport report = new MyTestReport(testSuiteName);
- report.startTestSuite(new StartRunnerEvent());
+ report.startJUnitTestSuite(new StartRunnerEvent());
TestId testId = new TestId("foo");
StartTestCaseEvent startTestEvent = new StartTestCaseEvent(testId, new
MyTestInfo());
@@ -130,10 +130,11 @@
private static void testTestCaseClass()
{
MyTestReport report = new MyTestReport(testSuiteName);
- report.startTestSuite(new StartRunnerEvent());
+ report.startJUnitTestSuite(new StartRunnerEvent());
// Set current tested class name
- report.setCurrentTestedClassName("org.jboss.portal.test.testedClass1");
+ report.addTestedSuiteName("org.jboss.portal.test.testedClass1");
+ report.addTestedSuiteName("blah");
TestId testId = new TestId("foo");
StartTestCaseEvent startTestEvent = new StartTestCaseEvent(testId, new
MyTestInfo());
@@ -153,17 +154,17 @@
Element testCase = child(e, TESTCASE);
Assert.assertEquals(TESTCASE, testCase.getNodeName());
- Assert.assertEquals("org.jboss.portal.test.testedClass1.foo",
testCase.getAttribute(ATTR_NAME));
+ Assert.assertEquals("org.jboss.portal.test.testedClass1.blah.foo",
testCase.getAttribute(ATTR_NAME));
Assert.assertEquals("0.02", testCase.getAttribute(ATTR_TIME));
-
- Assert.assertNull(child(e, ERROR));
+
+ Assert.assertNull(child(e, ERROR));
}
private static void testTestCaseFailure()
{
MyTestReport report = new MyTestReport(testSuiteName);
- report.startTestSuite(new StartRunnerEvent());
+ report.startJUnitTestSuite(new StartRunnerEvent());
TestId testId = new TestId("foo");
StartTestCaseEvent startTestEvent = new StartTestCaseEvent(testId, new
MyTestInfo());
Property changes on: modules/test/trunk/unit/src/main/org/jboss/unit/report
___________________________________________________________________
Name: svn:ignore
+ junit
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitReporter.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitReporter.java 2007-10-18
06:17:01 UTC (rev 8686)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitReporter.java 2007-10-18
10:10:11 UTC (rev 8687)
@@ -31,6 +31,7 @@
import org.jboss.unit.runner.TestRunnerEvent;
import org.jboss.unit.runner.event.EndRunnerEvent;
import org.jboss.unit.runner.event.EndTestCaseEvent;
+import org.jboss.unit.runner.event.EndTestSuiteEvent;
import org.jboss.unit.runner.event.RunnerFailureEvent;
import org.jboss.unit.runner.event.StartRunnerEvent;
import org.jboss.unit.runner.event.StartTestCaseEvent;
@@ -82,7 +83,7 @@
{
if (event instanceof StartRunnerEvent)
{
- report.startTestSuite((StartRunnerEvent) event);
+ report.startJUnitTestSuite((StartRunnerEvent) event);
}
else if (event instanceof EndRunnerEvent)
{
@@ -102,8 +103,12 @@
}
else if (event instanceof StartTestSuiteEvent)
{
- report.setCurrentTestedClassName(((StartTestSuiteEvent)
event).getTestInfo().getName());
+ report.addTestedSuiteName(((StartTestSuiteEvent)
event).getTestInfo().getName());
}
+ else if (event instanceof EndTestSuiteEvent)
+ {
+ report.removeLastTestedSuite();
+ }
else if (event instanceof StartTestCaseEvent)
{
report.startTest((StartTestCaseEvent) event);
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestReport.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestReport.java 2007-10-18
06:17:01 UTC (rev 8686)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestReport.java 2007-10-18
10:10:11 UTC (rev 8687)
@@ -35,6 +35,8 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
@@ -105,8 +107,8 @@
/** The timeStamp */
private String timeStamp;
- /** The current testSuiteName */
- private String currentTestedClassName;
+ /** The tested classes Stack */
+ private LinkedList<String> testSuiteNames = new LinkedList<String>();
/** .*/
private NumberFormat FORMAT = NumberFormat.getInstance();
@@ -121,7 +123,7 @@
}
- public void startTestSuite(StartRunnerEvent event)
+ public void startJUnitTestSuite(StartRunnerEvent event)
{
/** Create root element */
this.document = getDocumentBuilder().newDocument();
@@ -137,11 +139,18 @@
*/
}
- public void setCurrentTestedClassName(String testedClassName)
+ // add tested class to stack (starttestsuiteevent)
+ public void addTestedSuiteName(String testedClassName)
{
- this.currentTestedClassName = testedClassName;
+ this.testSuiteNames.add(testedClassName);
}
+ // remove last from stack (endtestsuiteevent)
+ public void removeLastTestedSuite()
+ {
+ this.testSuiteNames.removeLast();
+ }
+
public void startTest(StartTestCaseEvent event)
{
this.startedTests.put(event.getTestId(), event.getTestInfo());
@@ -170,10 +179,10 @@
/** The testcase name */
StringBuffer nb = new StringBuffer();
/** The current tested Class */
- if (this.currentTestedClassName != null)
+ for(String testSuiteName : this.testSuiteNames)
{
- nb.append(this.currentTestedClassName);
- nb.append(".");
+ nb.append(testSuiteName);
+ nb.append(".");
}
/** TestId */
for(int i = 0; i < testId.getLength(); i ++)
Show replies by date