Thread: [P-unit-devel] SF.net SVN: p-unit: [48] trunk/punit.test/src/tests/api/org/punit
Status: Beta
Brought to you by:
zhanghuangzhu
|
From: <zha...@us...> - 2007-05-13 21:36:37
|
Revision: 48
http://p-unit.svn.sourceforge.net/p-unit/?rev=48&view=rev
Author: zhanghuangzhu
Date: 2007-05-13 14:36:39 -0700 (Sun, 13 May 2007)
Log Message:
-----------
Andrew Zhang: refactored org.punit.reporter package.
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
Added Paths:
-----------
trunk/punit.test/src/tests/api/org/punit/reporter/
trunk/punit.test/src/tests/api/org/punit/reporter/logger/
trunk/punit.test/src/tests/api/org/punit/reporter/logger/PUnitLoggerTest.java
Removed Paths:
-------------
trunk/punit.test/src/tests/api/org/punit/reporter/logger/PUnitLoggerTest.java
Modified: trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2007-05-13 21:35:42 UTC (rev 47)
+++ trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2007-05-13 21:36:39 UTC (rev 48)
@@ -3,7 +3,7 @@
import junit.framework.*;
import tests.api.org.punit.builder.*;
import tests.api.org.punit.exception.*;
-import tests.api.org.punit.logger.*;
+import tests.api.org.punit.reporter.logger.*;
import tests.api.org.punit.runner.*;
import tests.api.org.punit.util.*;
import tests.api.org.punit.watcher.*;
Copied: trunk/punit.test/src/tests/api/org/punit/reporter/logger (from rev 28, trunk/punit.test/src/tests/api/org/punit/logger)
Deleted: trunk/punit.test/src/tests/api/org/punit/reporter/logger/PUnitLoggerTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/logger/PUnitLoggerTest.java 2007-05-12 13:13:40 UTC (rev 28)
+++ trunk/punit.test/src/tests/api/org/punit/reporter/logger/PUnitLoggerTest.java 2007-05-13 21:36:39 UTC (rev 48)
@@ -1,67 +0,0 @@
-package tests.api.org.punit.logger;
-
-import java.io.*;
-import java.util.logging.*;
-
-import junit.framework.*;
-
-import org.punit.logger.*;
-
-public class PUnitLoggerTest extends TestCase {
- private static MockPrintStream _mockPrintStream = new MockPrintStream(
- System.err);
-
- static {
- PUnitLogger.setOutputStream(_mockPrintStream);
- }
-
- protected void setUp() throws Exception {
- reset();
- }
-
- protected void tearDown() {
- PUnitLogger.reset();
- }
-
- public void test() {
- PUnitLogger.setLogLevel(Level.ALL);
- PUnitLogger.log(null, Level.INFO);
- assertPrinted();
-
- PUnitLogger.setLogLevel(Level.INFO);
- reset();
- PUnitLogger.log(null, Level.SEVERE);
- assertPrinted();
-
- reset();
- PUnitLogger.log(null, Level.FINE);
- assertNotPrinted();
-
- }
-
- private void reset() {
- _mockPrintStream._printed = false;
- }
-
- private void assertPrinted() {
- assertTrue(_mockPrintStream._printed);
- }
-
- private void assertNotPrinted() {
- assertFalse(_mockPrintStream._printed);
- }
-
- private static class MockPrintStream extends PrintStream {
-
- public boolean _printed;
-
- public MockPrintStream(OutputStream out) {
- super(out);
- }
-
- public void print(String s) {
- _printed = true;
- }
-
- }
-}
Copied: trunk/punit.test/src/tests/api/org/punit/reporter/logger/PUnitLoggerTest.java (from rev 36, trunk/punit.test/src/tests/api/org/punit/logger/PUnitLoggerTest.java)
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/reporter/logger/PUnitLoggerTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/reporter/logger/PUnitLoggerTest.java 2007-05-13 21:36:39 UTC (rev 48)
@@ -0,0 +1,59 @@
+package tests.api.org.punit.reporter.logger;
+
+import java.io.*;
+import java.util.logging.*;
+
+import junit.framework.*;
+
+import org.punit.reporter.logger.*;
+
+public class PUnitLoggerTest extends TestCase {
+ ConsoleLoggerListener _logger = new ConsoleLoggerListener();
+
+ private MockPrintStream _mockPrintStream;
+
+ protected void setUp() throws Exception {
+ _mockPrintStream = new MockPrintStream(System.err);
+ _logger.setOutputStream(_mockPrintStream);
+ }
+
+ public void test1() {
+ _logger.setLogLevel(Level.ALL);
+ _logger.log(null, Level.INFO);
+ assertPrinted();
+ }
+
+ public void test2() {
+ _logger.setLogLevel(Level.INFO);
+ _logger.log(null, Level.SEVERE);
+ assertPrinted();
+ }
+
+ public void test3() {
+ _logger.setLogLevel(Level.FINE);
+ _logger.log(null, Level.FINER);
+ assertNotPrinted();
+ }
+
+ private void assertPrinted() {
+ assertTrue(_mockPrintStream._printed);
+ }
+
+ private void assertNotPrinted() {
+ assertFalse(_mockPrintStream._printed);
+ }
+
+ private static class MockPrintStream extends PrintStream {
+
+ public boolean _printed;
+
+ public MockPrintStream(OutputStream out) {
+ super(out);
+ }
+
+ public void print(String s) {
+ _printed = true;
+ }
+
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2007-05-16 18:49:15
|
Revision: 85
http://p-unit.svn.sourceforge.net/p-unit/?rev=85&view=rev
Author: zhanghuangzhu
Date: 2007-05-16 11:49:17 -0700 (Wed, 16 May 2007)
Log Message:
-----------
Andrew Zhang: added some serialization test cases.
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
trunk/punit.test/src/tests/api/org/punit/watcher/MemoryWatcherTest.java
trunk/punit.test/src/tests/api/org/punit/watcher/TimeWatcherTest.java
Added Paths:
-----------
trunk/punit.test/src/tests/api/org/punit/reporter/stream/
trunk/punit.test/src/tests/api/org/punit/reporter/stream/PUnitStreamListenerTest.java
Removed Paths:
-------------
trunk/punit.test/src/tests/api/org/punit/reporter/logger/
trunk/punit.test/src/tests/api/org/punit/reporter/stream/PUnitLoggerTest.java
Modified: trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2007-05-16 18:15:20 UTC (rev 84)
+++ trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2007-05-16 18:49:17 UTC (rev 85)
@@ -3,7 +3,7 @@
import junit.framework.*;
import tests.api.org.punit.builder.*;
import tests.api.org.punit.exception.*;
-import tests.api.org.punit.reporter.logger.*;
+import tests.api.org.punit.reporter.stream.*;
import tests.api.org.punit.runner.*;
import tests.api.org.punit.util.*;
import tests.api.org.punit.watcher.*;
@@ -30,7 +30,7 @@
PUnitAbstractTestMethodBuilderTest.class,
PUnitConcurrentParameterizableRunnerTest.class,
PUnitConcurrentRunnerTest.class,
- PUnitLoggerTest.class,
+ PUnitStreamListenerTest.class,
PUnitParameterizableTestMethodBuilderTest.class,
PUnitSoloParameterizableRunnerTest.class,
PUnitSoloRunnerTest.class,
Copied: trunk/punit.test/src/tests/api/org/punit/reporter/stream (from rev 72, trunk/punit.test/src/tests/api/org/punit/reporter/logger)
Deleted: trunk/punit.test/src/tests/api/org/punit/reporter/stream/PUnitLoggerTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/reporter/logger/PUnitLoggerTest.java 2007-05-14 15:30:21 UTC (rev 72)
+++ trunk/punit.test/src/tests/api/org/punit/reporter/stream/PUnitLoggerTest.java 2007-05-16 18:49:17 UTC (rev 85)
@@ -1,60 +0,0 @@
-package tests.api.org.punit.reporter.logger;
-
-import java.io.*;
-import java.util.logging.*;
-
-import junit.framework.*;
-
-import org.punit.reporter.stream.*;
-import org.punit.reporter.stream.console.*;
-
-public class PUnitLoggerTest extends TestCase {
- ConsoleLoggerListener _logger = new ConsoleLoggerListener();
-
- private MockPrintStream _mockPrintStream;
-
- protected void setUp() throws Exception {
- _mockPrintStream = new MockPrintStream(System.err);
- _logger.setOutputStream(_mockPrintStream);
- }
-
- public void test1() {
- _logger.setLogLevel(Level.ALL);
- _logger.log(null, Level.INFO);
- assertPrinted();
- }
-
- public void test2() {
- _logger.setLogLevel(Level.INFO);
- _logger.log(null, Level.SEVERE);
- assertPrinted();
- }
-
- public void test3() {
- _logger.setLogLevel(Level.FINE);
- _logger.log(null, Level.FINER);
- assertNotPrinted();
- }
-
- private void assertPrinted() {
- assertTrue(_mockPrintStream._printed);
- }
-
- private void assertNotPrinted() {
- assertFalse(_mockPrintStream._printed);
- }
-
- private static class MockPrintStream extends PrintStream {
-
- public boolean _printed;
-
- public MockPrintStream(OutputStream out) {
- super(out);
- }
-
- public void print(String s) {
- _printed = true;
- }
-
- }
-}
Added: trunk/punit.test/src/tests/api/org/punit/reporter/stream/PUnitStreamListenerTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/reporter/stream/PUnitStreamListenerTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/reporter/stream/PUnitStreamListenerTest.java 2007-05-16 18:49:17 UTC (rev 85)
@@ -0,0 +1,69 @@
+package tests.api.org.punit.reporter.stream;
+
+import java.io.*;
+import java.util.*;
+import java.util.logging.*;
+
+import junit.framework.*;
+
+import org.punit.reporter.stream.console.*;
+import org.punit.runner.*;
+
+import tests.api.org.punit.runner.*;
+import tests.util.*;
+
+public class PUnitStreamListenerTest extends TestCase {
+ ConsoleLoggerListener _logger = new ConsoleLoggerListener();
+
+ private MockPrintStream _mockPrintStream;
+
+ protected void setUp() throws Exception {
+ _mockPrintStream = new MockPrintStream(System.err);
+ _logger.setOutputStream(_mockPrintStream);
+ }
+
+ public void test1() {
+ _logger.setLogLevel(Level.ALL);
+ _logger.log(null, Level.INFO);
+ assertPrinted();
+ }
+
+ public void test2() {
+ _logger.setLogLevel(Level.INFO);
+ _logger.log(null, Level.SEVERE);
+ assertPrinted();
+ }
+
+ public void test3() {
+ _logger.setLogLevel(Level.FINE);
+ _logger.log(null, Level.FINER);
+ assertNotPrinted();
+ }
+
+ public void testSerializable() throws Exception {
+ ConsoleLoggerListener logger = (ConsoleLoggerListener) TestUtil.getSerialiableObject(_logger);
+ assertSame(System.err, logger.printStream());
+ }
+
+ private void assertPrinted() {
+ assertTrue(_mockPrintStream._printed);
+ }
+
+ private void assertNotPrinted() {
+ assertFalse(_mockPrintStream._printed);
+ }
+
+ private static class MockPrintStream extends PrintStream {
+
+ public boolean _printed;
+
+ public MockPrintStream(OutputStream out) {
+ super(out);
+ }
+
+ public void print(String s) {
+ _printed = true;
+ }
+
+ }
+}
Modified: trunk/punit.test/src/tests/api/org/punit/watcher/MemoryWatcherTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/watcher/MemoryWatcherTest.java 2007-05-16 18:15:20 UTC (rev 84)
+++ trunk/punit.test/src/tests/api/org/punit/watcher/MemoryWatcherTest.java 2007-05-16 18:49:17 UTC (rev 85)
@@ -4,6 +4,8 @@
import org.punit.watcher.*;
+import tests.util.*;
+
public class MemoryWatcherTest extends TestCase {
private MemoryWatcher _watcher;
@@ -27,4 +29,9 @@
assertTrue(memoryConsumed < data.length * 1.5);
assertTrue(memoryConsumed > data.length/2);
}
+
+ public void testSerializable() throws Exception {
+ MemoryWatcher watcher = (MemoryWatcher) TestUtil.getSerialiableObject(_watcher);
+ assertNotNull(watcher);
+ }
}
Modified: trunk/punit.test/src/tests/api/org/punit/watcher/TimeWatcherTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/watcher/TimeWatcherTest.java 2007-05-16 18:15:20 UTC (rev 84)
+++ trunk/punit.test/src/tests/api/org/punit/watcher/TimeWatcherTest.java 2007-05-16 18:49:17 UTC (rev 85)
@@ -4,6 +4,8 @@
import org.punit.watcher.*;
+import tests.util.*;
+
public class TimeWatcherTest extends TestCase {
private static final int SLEEP_TIME = 500;
private TimeWatcher _watcher;
@@ -22,4 +24,9 @@
assertTrue(timeElapsed < SLEEP_TIME * 1.2);
assertTrue(timeElapsed > SLEEP_TIME * 0.8);
}
+
+ public void testSerializable() throws Exception {
+ TimeWatcher watcher = (TimeWatcher) TestUtil.getSerialiableObject(_watcher);
+ assertNotNull(watcher);
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2007-05-17 09:02:45
|
Revision: 91
http://p-unit.svn.sourceforge.net/p-unit/?rev=91&view=rev
Author: zhanghuangzhu
Date: 2007-05-17 02:02:47 -0700 (Thu, 17 May 2007)
Log Message:
-----------
Andrew Zhang: refined tests.
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/runner/PUnitConcurrentRunnerTest.java
trunk/punit.test/src/tests/api/org/punit/testclasses/ConcurrentParameterizableTestClass.java
trunk/punit.test/src/tests/api/org/punit/testclasses/ParameterizableTestClass.java
Modified: trunk/punit.test/src/tests/api/org/punit/runner/PUnitConcurrentRunnerTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/runner/PUnitConcurrentRunnerTest.java 2007-05-17 08:32:22 UTC (rev 90)
+++ trunk/punit.test/src/tests/api/org/punit/runner/PUnitConcurrentRunnerTest.java 2007-05-17 09:02:47 UTC (rev 91)
@@ -38,6 +38,12 @@
assertPUnitTestNotRun();
}
+ public void testRunParameterizable() throws Exception{
+ ConcurrentParameterizableTestClass.reset();
+ _runner.run(ConcurrentParameterizableTestClass.class);
+ ConcurrentParameterizableTestClass.assertTestClassRun();
+ }
+
public void testRunTestSuite() {
ConcurrentTestClass.reset();
TestClass.reset();
Modified: trunk/punit.test/src/tests/api/org/punit/testclasses/ConcurrentParameterizableTestClass.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/testclasses/ConcurrentParameterizableTestClass.java 2007-05-17 08:32:22 UTC (rev 90)
+++ trunk/punit.test/src/tests/api/org/punit/testclasses/ConcurrentParameterizableTestClass.java 2007-05-17 09:02:47 UTC (rev 91)
@@ -1,5 +1,7 @@
package tests.api.org.punit.testclasses;
+import junit.framework.*;
+
import org.punit.type.*;
import tests.util.*;
@@ -89,4 +91,12 @@
return COCURRENT_COUNT;
}
+ public static void assertTestClassRun() {
+ Assert.assertEquals(SUM * COCURRENT_COUNT, _test1);
+ Assert.assertFalse(_test2);
+ Assert.assertTrue(_setUpBefore);
+ Assert.assertTrue(_setUpAfter);
+ Assert.assertTrue(_tearDownBefore);
+ Assert.assertTrue(_tearDownAfter);
+ }
}
Modified: trunk/punit.test/src/tests/api/org/punit/testclasses/ParameterizableTestClass.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/testclasses/ParameterizableTestClass.java 2007-05-17 08:32:22 UTC (rev 90)
+++ trunk/punit.test/src/tests/api/org/punit/testclasses/ParameterizableTestClass.java 2007-05-17 09:02:47 UTC (rev 91)
@@ -76,13 +76,14 @@
}
public static void assertTestClassRun() {
- Assert.assertEquals(SUM, ParameterizableTestClass._test1);
+ Assert.assertEquals(SUM, _test1);
Assert.assertFalse(_test2);
Assert.assertTrue(_setUpBefore);
Assert.assertTrue(_setUpAfter);
Assert.assertTrue(_tearDownBefore);
Assert.assertTrue(_tearDownAfter);
}
+
static class Parameter1 implements Parameter {
int value;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2007-05-19 08:33:49
|
Revision: 127
http://p-unit.svn.sourceforge.net/p-unit/?rev=127&view=rev
Author: zhanghuangzhu
Date: 2007-05-19 01:33:46 -0700 (Sat, 19 May 2007)
Log Message:
-----------
Andrew Zhang: added a test.
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
Added Paths:
-----------
trunk/punit.test/src/tests/api/org/punit/runner/method/
trunk/punit.test/src/tests/api/org/punit/runner/method/AbstractTestMethodRunnerTest.java
Modified: trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2007-05-19 08:26:51 UTC (rev 126)
+++ trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2007-05-19 08:33:46 UTC (rev 127)
@@ -5,6 +5,7 @@
import tests.api.org.punit.exception.*;
import tests.api.org.punit.reporter.stream.*;
import tests.api.org.punit.runner.*;
+import tests.api.org.punit.runner.method.*;
import tests.api.org.punit.util.*;
import tests.api.org.punit.watcher.*;
import extension.tests.api.org.punit.reporter.chart.*;
@@ -25,6 +26,7 @@
public static Class[] testCases() {
return new Class[] {
AbstractChartReporterTest.class,
+ AbstractTestMethodRunnerTest.class,
ConcurrentExceptionTest.class,
LoggerUtilTest.class,
MemoryWatcherTest.class,
Added: trunk/punit.test/src/tests/api/org/punit/runner/method/AbstractTestMethodRunnerTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/runner/method/AbstractTestMethodRunnerTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/runner/method/AbstractTestMethodRunnerTest.java 2007-05-19 08:33:46 UTC (rev 127)
@@ -0,0 +1,41 @@
+package tests.api.org.punit.runner.method;
+
+import java.util.*;
+
+import junit.framework.*;
+
+import org.punit.runner.method.*;
+import org.punit.watcher.*;
+
+public class AbstractTestMethodRunnerTest extends TestCase {
+ private MockTestMethodRunnerTest _mockRunner = new MockTestMethodRunnerTest();
+
+ public void testWatchers() {
+ List watchers = _mockRunner.watchers();
+ assertEquals(2, watchers.size()); // time, and memory watchers
+
+ _mockRunner.removeMemoryWatcher();
+ watchers = _mockRunner.watchers();
+ assertEquals(1, watchers.size());
+
+ _mockRunner.removeMemoryWatcher();
+ watchers = _mockRunner.watchers();
+ assertEquals(1, watchers.size());
+
+ _mockRunner.removeTimeWatcher();
+ watchers = _mockRunner.watchers();
+ assertEquals(0, watchers.size());
+
+ _mockRunner.addWatcher(new TimeWatcher());
+ watchers = _mockRunner.watchers();
+ assertEquals(1, watchers.size());
+ }
+
+ static class MockTestMethodRunnerTest extends AbstractTestMethodRunner {
+
+ protected void runImpl() throws Throwable {
+ throw new UnsupportedOperationException();
+ }
+
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2007-05-31 06:16:29
|
Revision: 178
http://p-unit.svn.sourceforge.net/p-unit/?rev=178&view=rev
Author: zhanghuangzhu
Date: 2007-05-30 23:16:30 -0700 (Wed, 30 May 2007)
Log Message:
-----------
Andrew Zhang: refactored package name.
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
Added Paths:
-----------
trunk/punit.test/src/tests/api/org/punit/method/
trunk/punit.test/src/tests/api/org/punit/method/AnnotationMethodFilterTest.java
trunk/punit.test/src/tests/api/org/punit/method/ByNameMethodFilterTest.java
trunk/punit.test/src/tests/api/org/punit/method/builder/
trunk/punit.test/src/tests/api/org/punit/method/builder/MethodBuilderTest.java
trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestMethodBuilderTest.java
trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestSuiteBuilderTest.java
Removed Paths:
-------------
trunk/punit.test/src/tests/api/org/punit/builder/MethodBuilderTest.java
trunk/punit.test/src/tests/api/org/punit/builder/PUnitTestMethodBuilderTest.java
trunk/punit.test/src/tests/api/org/punit/builder/PUnitTestSuiteBuilderTest.java
trunk/punit.test/src/tests/api/org/punit/builder/method/
trunk/punit.test/src/tests/api/org/punit/method/AnnotationMethodFilterTest.java
trunk/punit.test/src/tests/api/org/punit/method/ByNameMethodFilterTest.java
Modified: trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2007-05-31 06:11:41 UTC (rev 177)
+++ trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2007-05-31 06:16:30 UTC (rev 178)
@@ -2,9 +2,9 @@
import junit.framework.*;
import tests.api.org.punit.assertion.*;
-import tests.api.org.punit.builder.*;
-import tests.api.org.punit.builder.method.*;
import tests.api.org.punit.exception.*;
+import tests.api.org.punit.method.*;
+import tests.api.org.punit.method.builder.*;
import tests.api.org.punit.reporter.stream.*;
import tests.api.org.punit.runner.*;
import tests.api.org.punit.runner.method.*;
Deleted: trunk/punit.test/src/tests/api/org/punit/builder/MethodBuilderTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/builder/MethodBuilderTest.java 2007-05-31 06:11:41 UTC (rev 177)
+++ trunk/punit.test/src/tests/api/org/punit/builder/MethodBuilderTest.java 2007-05-31 06:16:30 UTC (rev 178)
@@ -1,61 +0,0 @@
-/* (C) Copyright 2007, by Andrew Zhang */
-
-package tests.api.org.punit.builder;
-
-import junit.framework.*;
-
-import org.punit.method.*;
-import org.punit.method.builder.*;
-import org.punit.runner.*;
-
-import tests.api.org.punit.testclasses.*;
-import tests.util.*;
-
-public class MethodBuilderTest extends TestCase {
-
- private MethodBuilderImpl _builder;
-
- public void setUp() {
- _builder = new MethodBuilderImpl();
- _builder.setMethodFilter(new ByNameMethodFilter());
- }
-
- public void testAddInterfaces() {
- _builder.setMethodFilter(new AnnotationMethodFilter());
- Object[] methods = _builder.buildTestMethods(TestInterfaceImpl1.class)
- .toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArrayContent(names, new String[] { "method1" }); //$NON-NLS-1$
- }
-
- public void testBuildTestMethods1() {
- Object[] methods = _builder.buildTestMethods(TestClass1.class)
- .toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArrayContains(names, new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
- "testa", "testb" }); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBuildTestMethods_SubClass() {
- Object[] methods = _builder.buildTestMethods(SubTestClass.class).toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArrayContains(names, new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
- "testa", "testb" }); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBuildTestMethods2() {
- Object[] methods = _builder.buildTestMethods(TestClass2.class).toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArrayContent(names, new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
- "testa", "testb" }); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBuildTestMethods3() {
- Object[] methods = _builder.buildTestMethods(TestClass3.class).toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArrayContent(names, new String[] {
- "test1", "test2", "testa", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "testb" }); //$NON-NLS-1$
- }
-
-}
Deleted: trunk/punit.test/src/tests/api/org/punit/builder/PUnitTestMethodBuilderTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/builder/PUnitTestMethodBuilderTest.java 2007-05-31 06:11:41 UTC (rev 177)
+++ trunk/punit.test/src/tests/api/org/punit/builder/PUnitTestMethodBuilderTest.java 2007-05-31 06:16:30 UTC (rev 178)
@@ -1,51 +0,0 @@
-package tests.api.org.punit.builder;
-
-import junit.framework.*;
-
-import org.punit.method.*;
-import org.punit.method.builder.*;
-import org.punit.runner.*;
-
-import tests.api.org.punit.testclasses.*;
-import tests.util.*;
-
-public class PUnitTestMethodBuilderTest extends TestCase {
- private MethodBuilderImpl _builder;
-
- protected void setUp() throws Exception {
- _builder = new MethodBuilderImpl();
- _builder.setMethodFilter(new ByNameMethodFilter());
- }
-
- public void testBuildTestMethods1() {
- Object[] methods = _builder.buildTestMethods(TestClass1.class)
- .toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArrayContent(new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
- "testa", "testb" }, names); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBuildTestMethods_SubClass() {
- Object[] methods = _builder.buildTestMethods(SubTestClass.class)
- .toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArrayContent(new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
- "testa", "testb" }, names); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBuildTestMethods2() {
- Object[] methods = _builder.buildTestMethods(TestClass2.class)
- .toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArrayContent(names, new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
- "testa", "testb" }); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBuildTestMethods3() {
- Object[] methods = _builder.buildTestMethods(TestClass3.class)
- .toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArray(names, new String[] { "test1", "test2", "testa", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "testb" }); //$NON-NLS-1$
- }
-}
Deleted: trunk/punit.test/src/tests/api/org/punit/builder/PUnitTestSuiteBuilderTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/builder/PUnitTestSuiteBuilderTest.java 2007-05-31 06:11:41 UTC (rev 177)
+++ trunk/punit.test/src/tests/api/org/punit/builder/PUnitTestSuiteBuilderTest.java 2007-05-31 06:16:30 UTC (rev 178)
@@ -1,66 +0,0 @@
-package tests.api.org.punit.builder;
-
-import junit.framework.*;
-
-import org.punit.suite.builder.*;
-
-import tests.api.org.punit.testclasses.*;
-import tests.util.*;
-
-public class PUnitTestSuiteBuilderTest extends TestCase {
- private TestSuiteBuilderImpl _testSuiteBuidler;
-
- protected void setUp() throws Exception {
- _testSuiteBuidler = new TestSuiteBuilderImpl();
- }
-
- public void testBuildTestClasses1() {
- Object[] classes = _testSuiteBuidler.buildTestClasses(TestClass1.class);
- AssertUtil.assertArray(classes, new Class[] { TestClass1.class });
- }
-
- public void testBuildTestClasses2() {
- Object[] classes = _testSuiteBuidler.buildTestClasses(TestSuite1.class);
- Class[] expectedClasses = new Class[] { TestClass1.class,
- TestClass2.class, TestClass3.class };
-
- assertEquals(expectedClasses.length + 2, classes.length); // suite labels
-
- TestSuiteLabel label = (TestSuiteLabel) classes[0];
- assertSame(TestSuite1.class, label.suite().getClass());
- assertTrue(label.isStart());
-
- label = (TestSuiteLabel) classes[classes.length - 1];
- assertSame(TestSuite1.class, label.suite().getClass());
- assertFalse(label.isStart());
-
- AssertUtil.assertArrayContains(classes, expectedClasses);
- }
-
- public void testBuildTestClasses3() {
- Object[] classes = _testSuiteBuidler.buildTestClasses(TestSuite2.class);
- Class[] expectedClasses = new Class[] { TestClass4.class,
- TestClass1.class, TestClass2.class, TestClass3.class, TestClass5.class };
-
- assertEquals(expectedClasses.length + 4, classes.length); // suite labels
-
- TestSuiteLabel label = (TestSuiteLabel) classes[0];
- assertSame(TestSuite2.class, label.suite().getClass());
- assertTrue(label.isStart());
-
- label = (TestSuiteLabel) classes[classes.length - 1];
- assertSame(TestSuite2.class, label.suite().getClass());
- assertFalse(label.isStart());
-
- label = (TestSuiteLabel) classes[2];
- assertSame(TestSuite1.class, label.suite().getClass());
- assertTrue(label.isStart());
-
- label = (TestSuiteLabel) classes[6];
- assertSame(TestSuite1.class, label.suite().getClass());
- assertFalse(label.isStart());
-
- AssertUtil.assertArrayContains(classes, expectedClasses);
- }
-
-}
Copied: trunk/punit.test/src/tests/api/org/punit/method (from rev 176, trunk/punit.test/src/tests/api/org/punit/builder/method)
Deleted: trunk/punit.test/src/tests/api/org/punit/method/AnnotationMethodFilterTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/builder/method/AnnotationMethodFilterTest.java 2007-05-31 06:09:04 UTC (rev 176)
+++ trunk/punit.test/src/tests/api/org/punit/method/AnnotationMethodFilterTest.java 2007-05-31 06:16:30 UTC (rev 178)
@@ -1,82 +0,0 @@
-/* (C) Copyright 2007, by Andrew Zhang */
-
-package tests.api.org.punit.builder.method;
-
-import java.lang.reflect.*;
-
-import junit.framework.*;
-
-import org.punit.annotation.Test;
-import org.punit.builder.method.*;
-import org.punit.method.builder.*;
-import org.punit.util.*;
-
-public class AnnotationMethodFilterTest extends TestCase {
- AnnotationMethodFilter _filter = new AnnotationMethodFilter();
-
- public void testIsTestMethod() {
- Method method;
- method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
- assertFalse(_filter.isTestMethod(method));
-
- method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
- assertTrue(_filter.isTestMethod(method));
- }
-
- public void testGetCheckMethod() {
- Method method, checkMethod;
- method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
- assertFalse(_filter.isTestMethod(method));
- checkMethod = _filter.getCheckMethod(method);
- assertNull(checkMethod);
-
- method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
- assertTrue(_filter.isTestMethod(method));
- checkMethod = _filter.getCheckMethod(method);
- assertEquals("checkTest2", checkMethod.getName()); //$NON-NLS-1$
-
- method = ReflectionUtil.getMethod(getClass(), "_test3", new Class[] {}); //$NON-NLS-1$
- assertTrue(_filter.isTestMethod(method));
- checkMethod = _filter.getCheckMethod(method);
- assertEquals("check__test3", checkMethod.getName()); //$NON-NLS-1$
- }
-
- public void testGetExpectedException() {
- Method method, checkMethod;
- Class exception;
-
- method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
- exception = _filter.getExpectedException(method);
- assertNull(exception);
-
- method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
- exception = _filter.getExpectedException(method);
- assertSame(NullPointerException.class, exception);
-
- method = ReflectionUtil.getMethod(getClass(), "_test3", new Class[] {}); //$NON-NLS-1$
- exception = _filter.getExpectedException(method);
- assertNull(exception);
- }
-
- public void _test1() {
-
- }
-
- @Test(checkMethod="checkTest2", expected=NullPointerException.class)
- public void _test2() {
-
- }
-
- public void checkTest2() {
-
- }
-
- @Test
- public void _test3() {
-
- }
-
- public void check__test3() {
-
- }
-}
Copied: trunk/punit.test/src/tests/api/org/punit/method/AnnotationMethodFilterTest.java (from rev 177, trunk/punit.test/src/tests/api/org/punit/builder/method/AnnotationMethodFilterTest.java)
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/AnnotationMethodFilterTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/method/AnnotationMethodFilterTest.java 2007-05-31 06:16:30 UTC (rev 178)
@@ -0,0 +1,82 @@
+/* (C) Copyright 2007, by Andrew Zhang */
+
+package tests.api.org.punit.method;
+
+import java.lang.reflect.*;
+
+import junit.framework.*;
+
+import org.punit.annotation.Test;
+import org.punit.method.*;
+import org.punit.method.builder.*;
+import org.punit.util.*;
+
+public class AnnotationMethodFilterTest extends TestCase {
+ AnnotationMethodFilter _filter = new AnnotationMethodFilter();
+
+ public void testIsTestMethod() {
+ Method method;
+ method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
+ assertFalse(_filter.isTestMethod(method));
+
+ method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
+ assertTrue(_filter.isTestMethod(method));
+ }
+
+ public void testGetCheckMethod() {
+ Method method, checkMethod;
+ method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
+ assertFalse(_filter.isTestMethod(method));
+ checkMethod = _filter.getCheckMethod(method);
+ assertNull(checkMethod);
+
+ method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
+ assertTrue(_filter.isTestMethod(method));
+ checkMethod = _filter.getCheckMethod(method);
+ assertEquals("checkTest2", checkMethod.getName()); //$NON-NLS-1$
+
+ method = ReflectionUtil.getMethod(getClass(), "_test3", new Class[] {}); //$NON-NLS-1$
+ assertTrue(_filter.isTestMethod(method));
+ checkMethod = _filter.getCheckMethod(method);
+ assertEquals("check__test3", checkMethod.getName()); //$NON-NLS-1$
+ }
+
+ public void testGetExpectedException() {
+ Method method, checkMethod;
+ Class exception;
+
+ method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
+ exception = _filter.getExpectedException(method);
+ assertNull(exception);
+
+ method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
+ exception = _filter.getExpectedException(method);
+ assertSame(NullPointerException.class, exception);
+
+ method = ReflectionUtil.getMethod(getClass(), "_test3", new Class[] {}); //$NON-NLS-1$
+ exception = _filter.getExpectedException(method);
+ assertNull(exception);
+ }
+
+ public void _test1() {
+
+ }
+
+ @Test(checkMethod="checkTest2", expected=NullPointerException.class)
+ public void _test2() {
+
+ }
+
+ public void checkTest2() {
+
+ }
+
+ @Test
+ public void _test3() {
+
+ }
+
+ public void check__test3() {
+
+ }
+}
Deleted: trunk/punit.test/src/tests/api/org/punit/method/ByNameMethodFilterTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/builder/method/ByNameMethodFilterTest.java 2007-05-31 06:09:04 UTC (rev 176)
+++ trunk/punit.test/src/tests/api/org/punit/method/ByNameMethodFilterTest.java 2007-05-31 06:16:30 UTC (rev 178)
@@ -1,56 +0,0 @@
-/* (C) Copyright 2007, by Andrew Zhang */
-
-package tests.api.org.punit.builder.method;
-
-import java.lang.reflect.*;
-
-import junit.framework.*;
-
-import org.punit.builder.method.*;
-import org.punit.method.builder.*;
-import org.punit.util.*;
-
-public class ByNameMethodFilterTest extends TestCase {
- AnnotationMethodFilter _filter = new AnnotationMethodFilter();
-
- public void testIsTestMethod() {
- Method method;
- method = ReflectionUtil.getMethod(getClass(), "test1", new Class[] {}); //$NON-NLS-1$
- assertTrue(_filter.isTestMethod(method));
-
- method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
- assertFalse(_filter.isTestMethod(method));
- }
-
- public void testGetCheckMethod() {
- Method method, checkMethod;
- method = ReflectionUtil.getMethod(getClass(), "test1", new Class[] {}); //$NON-NLS-1$
- checkMethod = _filter.getCheckMethod(method);
- assertNull(checkMethod);
-
- method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
- checkMethod = _filter.getCheckMethod(method);
- assertEquals("check__test2", checkMethod.getName()); //$NON-NLS-1$
- }
-
-
- public void test1() {
-
- }
-
- public void _test2() {
-
- }
-
- public void check__test2() {
-
- }
-
- public void _test3() {
-
- }
-
- public void check__test3() {
-
- }
-}
Copied: trunk/punit.test/src/tests/api/org/punit/method/ByNameMethodFilterTest.java (from rev 177, trunk/punit.test/src/tests/api/org/punit/builder/method/ByNameMethodFilterTest.java)
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/ByNameMethodFilterTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/method/ByNameMethodFilterTest.java 2007-05-31 06:16:30 UTC (rev 178)
@@ -0,0 +1,56 @@
+/* (C) Copyright 2007, by Andrew Zhang */
+
+package tests.api.org.punit.method;
+
+import java.lang.reflect.*;
+
+import junit.framework.*;
+
+import org.punit.method.*;
+import org.punit.method.builder.*;
+import org.punit.util.*;
+
+public class ByNameMethodFilterTest extends TestCase {
+ AnnotationMethodFilter _filter = new AnnotationMethodFilter();
+
+ public void testIsTestMethod() {
+ Method method;
+ method = ReflectionUtil.getMethod(getClass(), "test1", new Class[] {}); //$NON-NLS-1$
+ assertTrue(_filter.isTestMethod(method));
+
+ method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
+ assertFalse(_filter.isTestMethod(method));
+ }
+
+ public void testGetCheckMethod() {
+ Method method, checkMethod;
+ method = ReflectionUtil.getMethod(getClass(), "test1", new Class[] {}); //$NON-NLS-1$
+ checkMethod = _filter.getCheckMethod(method);
+ assertNull(checkMethod);
+
+ method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
+ checkMethod = _filter.getCheckMethod(method);
+ assertEquals("check__test2", checkMethod.getName()); //$NON-NLS-1$
+ }
+
+
+ public void test1() {
+
+ }
+
+ public void _test2() {
+
+ }
+
+ public void check__test2() {
+
+ }
+
+ public void _test3() {
+
+ }
+
+ public void check__test3() {
+
+ }
+}
Copied: trunk/punit.test/src/tests/api/org/punit/method/builder/MethodBuilderTest.java (from rev 177, trunk/punit.test/src/tests/api/org/punit/builder/MethodBuilderTest.java)
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/builder/MethodBuilderTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/method/builder/MethodBuilderTest.java 2007-05-31 06:16:30 UTC (rev 178)
@@ -0,0 +1,61 @@
+/* (C) Copyright 2007, by Andrew Zhang */
+
+package tests.api.org.punit.method.builder;
+
+import junit.framework.*;
+
+import org.punit.method.*;
+import org.punit.method.builder.*;
+import org.punit.runner.*;
+
+import tests.api.org.punit.testclasses.*;
+import tests.util.*;
+
+public class MethodBuilderTest extends TestCase {
+
+ private MethodBuilderImpl _builder;
+
+ public void setUp() {
+ _builder = new MethodBuilderImpl();
+ _builder.setMethodFilter(new ByNameMethodFilter());
+ }
+
+ public void testAddInterfaces() {
+ _builder.setMethodFilter(new AnnotationMethodFilter());
+ Object[] methods = _builder.buildTestMethods(TestInterfaceImpl1.class)
+ .toArray();
+ String[] names = TestUtil.toMethodNameArray(methods);
+ AssertUtil.assertArrayContent(names, new String[] { "method1" }); //$NON-NLS-1$
+ }
+
+ public void testBuildTestMethods1() {
+ Object[] methods = _builder.buildTestMethods(TestClass1.class)
+ .toArray();
+ String[] names = TestUtil.toMethodNameArray(methods);
+ AssertUtil.assertArrayContains(names, new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
+ "testa", "testb" }); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBuildTestMethods_SubClass() {
+ Object[] methods = _builder.buildTestMethods(SubTestClass.class).toArray();
+ String[] names = TestUtil.toMethodNameArray(methods);
+ AssertUtil.assertArrayContains(names, new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
+ "testa", "testb" }); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBuildTestMethods2() {
+ Object[] methods = _builder.buildTestMethods(TestClass2.class).toArray();
+ String[] names = TestUtil.toMethodNameArray(methods);
+ AssertUtil.assertArrayContent(names, new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
+ "testa", "testb" }); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBuildTestMethods3() {
+ Object[] methods = _builder.buildTestMethods(TestClass3.class).toArray();
+ String[] names = TestUtil.toMethodNameArray(methods);
+ AssertUtil.assertArrayContent(names, new String[] {
+ "test1", "test2", "testa", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "testb" }); //$NON-NLS-1$
+ }
+
+}
Copied: trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestMethodBuilderTest.java (from rev 176, trunk/punit.test/src/tests/api/org/punit/builder/PUnitTestMethodBuilderTest.java)
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestMethodBuilderTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestMethodBuilderTest.java 2007-05-31 06:16:30 UTC (rev 178)
@@ -0,0 +1,51 @@
+package tests.api.org.punit.method.builder;
+
+import junit.framework.*;
+
+import org.punit.method.*;
+import org.punit.method.builder.*;
+import org.punit.runner.*;
+
+import tests.api.org.punit.testclasses.*;
+import tests.util.*;
+
+public class PUnitTestMethodBuilderTest extends TestCase {
+ private MethodBuilderImpl _builder;
+
+ protected void setUp() throws Exception {
+ _builder = new MethodBuilderImpl();
+ _builder.setMethodFilter(new ByNameMethodFilter());
+ }
+
+ public void testBuildTestMethods1() {
+ Object[] methods = _builder.buildTestMethods(TestClass1.class)
+ .toArray();
+ String[] names = TestUtil.toMethodNameArray(methods);
+ AssertUtil.assertArrayContent(new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
+ "testa", "testb" }, names); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBuildTestMethods_SubClass() {
+ Object[] methods = _builder.buildTestMethods(SubTestClass.class)
+ .toArray();
+ String[] names = TestUtil.toMethodNameArray(methods);
+ AssertUtil.assertArrayContent(new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
+ "testa", "testb" }, names); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBuildTestMethods2() {
+ Object[] methods = _builder.buildTestMethods(TestClass2.class)
+ .toArray();
+ String[] names = TestUtil.toMethodNameArray(methods);
+ AssertUtil.assertArrayContent(names, new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
+ "testa", "testb" }); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBuildTestMethods3() {
+ Object[] methods = _builder.buildTestMethods(TestClass3.class)
+ .toArray();
+ String[] names = TestUtil.toMethodNameArray(methods);
+ AssertUtil.assertArray(names, new String[] { "test1", "test2", "testa", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "testb" }); //$NON-NLS-1$
+ }
+}
Copied: trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestSuiteBuilderTest.java (from rev 176, trunk/punit.test/src/tests/api/org/punit/builder/PUnitTestSuiteBuilderTest.java)
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestSuiteBuilderTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestSuiteBuilderTest.java 2007-05-31 06:16:30 UTC (rev 178)
@@ -0,0 +1,66 @@
+package tests.api.org.punit.method.builder;
+
+import junit.framework.*;
+
+import org.punit.suite.builder.*;
+
+import tests.api.org.punit.testclasses.*;
+import tests.util.*;
+
+public class PUnitTestSuiteBuilderTest extends TestCase {
+ private TestSuiteBuilderImpl _testSuiteBuidler;
+
+ protected void setUp() throws Exception {
+ _testSuiteBuidler = new TestSuiteBuilderImpl();
+ }
+
+ public void testBuildTestClasses1() {
+ Object[] classes = _testSuiteBuidler.buildTestClasses(TestClass1.class);
+ AssertUtil.assertArray(classes, new Class[] { TestClass1.class });
+ }
+
+ public void testBuildTestClasses2() {
+ Object[] classes = _testSuiteBuidler.buildTestClasses(TestSuite1.class);
+ Class[] expectedClasses = new Class[] { TestClass1.class,
+ TestClass2.class, TestClass3.class };
+
+ assertEquals(expectedClasses.length + 2, classes.length); // suite labels
+
+ TestSuiteLabel label = (TestSuiteLabel) classes[0];
+ assertSame(TestSuite1.class, label.suite().getClass());
+ assertTrue(label.isStart());
+
+ label = (TestSuiteLabel) classes[classes.length - 1];
+ assertSame(TestSuite1.class, label.suite().getClass());
+ assertFalse(label.isStart());
+
+ AssertUtil.assertArrayContains(classes, expectedClasses);
+ }
+
+ public void testBuildTestClasses3() {
+ Object[] classes = _testSuiteBuidler.buildTestClasses(TestSuite2.class);
+ Class[] expectedClasses = new Class[] { TestClass4.class,
+ TestClass1.class, TestClass2.class, TestClass3.class, TestClass5.class };
+
+ assertEquals(expectedClasses.length + 4, classes.length); // suite labels
+
+ TestSuiteLabel label = (TestSuiteLabel) classes[0];
+ assertSame(TestSuite2.class, label.suite().getClass());
+ assertTrue(label.isStart());
+
+ label = (TestSuiteLabel) classes[classes.length - 1];
+ assertSame(TestSuite2.class, label.suite().getClass());
+ assertFalse(label.isStart());
+
+ label = (TestSuiteLabel) classes[2];
+ assertSame(TestSuite1.class, label.suite().getClass());
+ assertTrue(label.isStart());
+
+ label = (TestSuiteLabel) classes[6];
+ assertSame(TestSuite1.class, label.suite().getClass());
+ assertFalse(label.isStart());
+
+ AssertUtil.assertArrayContains(classes, expectedClasses);
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2007-06-04 06:52:37
|
Revision: 194
http://p-unit.svn.sourceforge.net/p-unit/?rev=194&view=rev
Author: zhanghuangzhu
Date: 2007-06-03 23:52:38 -0700 (Sun, 03 Jun 2007)
Log Message:
-----------
Andrew Zhang: added more test cases for AnnotationFilter
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
trunk/punit.test/src/tests/api/org/punit/method/builder/MethodBuilderTest.java
trunk/punit.test/src/tests/api/org/punit/testclasses/TestSuite2.java
Added Paths:
-----------
trunk/punit.test/src/tests/api/org/punit/method/AnnotationFilterTest.java
trunk/punit.test/src/tests/api/org/punit/method/NameConventionFilterTest.java
trunk/punit.test/src/tests/api/org/punit/method/builder/TestMethodBuilderTest.java
trunk/punit.test/src/tests/api/org/punit/method/builder/TestSuiteBuilderTest.java
trunk/punit.test/src/tests/api/org/punit/testclasses/ExcludedTestClass1.java
Removed Paths:
-------------
trunk/punit.test/src/tests/api/org/punit/method/AnnotationMethodFilterTest.java
trunk/punit.test/src/tests/api/org/punit/method/ByNameMethodFilterTest.java
trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestMethodBuilderTest.java
trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestSuiteBuilderTest.java
Modified: trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2007-06-04 06:37:45 UTC (rev 193)
+++ trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2007-06-04 06:52:38 UTC (rev 194)
@@ -31,8 +31,8 @@
AbstractRunnerTest.class,
AbstractTestMethodRunnerTest.class,
AssertTest.class,
- AnnotationMethodFilterTest.class,
- ByNameMethodFilterTest.class,
+ AnnotationFilterTest.class,
+ NameConventionFilterTest.class,
ConcurrentExceptionTest.class,
LoggerUtilTest.class,
MemoryWatcherTest.class,
@@ -42,8 +42,8 @@
ExecutorPoolTest.class,
extension.tests.api.org.punit.runner.PUnitSoloRunnerTest.class,
SoloRunnerTest.class,
- PUnitTestMethodBuilderTest.class,
- PUnitTestSuiteBuilderTest.class,
+ TestMethodBuilderTest.class,
+ TestSuiteBuilderTest.class,
ReflectionUtilTest.class,
TimeWatcherTest.class,
};
Copied: trunk/punit.test/src/tests/api/org/punit/method/AnnotationFilterTest.java (from rev 193, trunk/punit.test/src/tests/api/org/punit/method/AnnotationMethodFilterTest.java)
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/AnnotationFilterTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/method/AnnotationFilterTest.java 2007-06-04 06:52:38 UTC (rev 194)
@@ -0,0 +1,97 @@
+/* (C) Copyright 2007, by Andrew Zhang */
+
+package tests.api.org.punit.method;
+
+import java.lang.reflect.*;
+
+import junit.framework.*;
+
+import org.punit.annotation.Test;
+import org.punit.runner.*;
+import org.punit.util.*;
+
+public class AnnotationFilterTest extends TestCase {
+ AnnotationFilter _filter = new AnnotationFilter();
+
+ public void testIsExcluded() {
+ assertTrue(_filter.isExcluded(ExcludedClass.class));
+ assertFalse(_filter.isExcluded(NonExcludedClass.class));
+ assertFalse(_filter.isExcluded(getClass()));
+ }
+
+ public void testIsTestMethod() {
+ Method method;
+ method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
+ assertFalse(_filter.isTestMethod(method));
+
+ method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
+ assertTrue(_filter.isTestMethod(method));
+ }
+
+ public void testGetCheckMethod() {
+ Method method, checkMethod;
+ method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
+ assertFalse(_filter.isTestMethod(method));
+ checkMethod = _filter.getCheckMethod(method);
+ assertNull(checkMethod);
+
+ method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
+ assertTrue(_filter.isTestMethod(method));
+ checkMethod = _filter.getCheckMethod(method);
+ assertEquals("checkTest2", checkMethod.getName()); //$NON-NLS-1$
+
+ method = ReflectionUtil.getMethod(getClass(), "_test3", new Class[] {}); //$NON-NLS-1$
+ assertTrue(_filter.isTestMethod(method));
+ checkMethod = _filter.getCheckMethod(method);
+ assertEquals("check__test3", checkMethod.getName()); //$NON-NLS-1$
+ }
+
+ public void testGetExpectedException() {
+ Method method;
+ Class exception;
+
+ method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
+ exception = _filter.getExpectedException(method);
+ assertNull(exception);
+
+ method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
+ exception = _filter.getExpectedException(method);
+ assertSame(NullPointerException.class, exception);
+
+ method = ReflectionUtil.getMethod(getClass(), "_test3", new Class[] {}); //$NON-NLS-1$
+ exception = _filter.getExpectedException(method);
+ assertNull(exception);
+ }
+
+ public void _test1() {
+
+ }
+
+ @Test(checkMethod="checkTest2", expected=NullPointerException.class)
+ public void _test2() {
+
+ }
+
+ public void checkTest2() {
+
+ }
+
+ @Test
+ public void _test3() {
+
+ }
+
+ public void check__test3() {
+
+ }
+
+ @Test(excluded = true)
+ static class ExcludedClass {
+
+ }
+
+ @Test(excluded = false)
+ static class NonExcludedClass {
+
+ }
+}
Deleted: trunk/punit.test/src/tests/api/org/punit/method/AnnotationMethodFilterTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/AnnotationMethodFilterTest.java 2007-06-04 06:37:45 UTC (rev 193)
+++ trunk/punit.test/src/tests/api/org/punit/method/AnnotationMethodFilterTest.java 2007-06-04 06:52:38 UTC (rev 194)
@@ -1,97 +0,0 @@
-/* (C) Copyright 2007, by Andrew Zhang */
-
-package tests.api.org.punit.method;
-
-import java.lang.reflect.*;
-
-import junit.framework.*;
-
-import org.punit.annotation.Test;
-import org.punit.runner.*;
-import org.punit.util.*;
-
-public class AnnotationMethodFilterTest extends TestCase {
- AnnotationFilter _filter = new AnnotationFilter();
-
- public void testIsExcluded() {
- assertTrue(_filter.isExcluded(ExcludedClass.class));
- assertFalse(_filter.isExcluded(NonExcludedClass.class));
- assertFalse(_filter.isExcluded(getClass()));
- }
-
- public void testIsTestMethod() {
- Method method;
- method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
- assertFalse(_filter.isTestMethod(method));
-
- method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
- assertTrue(_filter.isTestMethod(method));
- }
-
- public void testGetCheckMethod() {
- Method method, checkMethod;
- method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
- assertFalse(_filter.isTestMethod(method));
- checkMethod = _filter.getCheckMethod(method);
- assertNull(checkMethod);
-
- method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
- assertTrue(_filter.isTestMethod(method));
- checkMethod = _filter.getCheckMethod(method);
- assertEquals("checkTest2", checkMethod.getName()); //$NON-NLS-1$
-
- method = ReflectionUtil.getMethod(getClass(), "_test3", new Class[] {}); //$NON-NLS-1$
- assertTrue(_filter.isTestMethod(method));
- checkMethod = _filter.getCheckMethod(method);
- assertEquals("check__test3", checkMethod.getName()); //$NON-NLS-1$
- }
-
- public void testGetExpectedException() {
- Method method;
- Class exception;
-
- method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
- exception = _filter.getExpectedException(method);
- assertNull(exception);
-
- method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
- exception = _filter.getExpectedException(method);
- assertSame(NullPointerException.class, exception);
-
- method = ReflectionUtil.getMethod(getClass(), "_test3", new Class[] {}); //$NON-NLS-1$
- exception = _filter.getExpectedException(method);
- assertNull(exception);
- }
-
- public void _test1() {
-
- }
-
- @Test(checkMethod="checkTest2", expected=NullPointerException.class)
- public void _test2() {
-
- }
-
- public void checkTest2() {
-
- }
-
- @Test
- public void _test3() {
-
- }
-
- public void check__test3() {
-
- }
-
- @Test(excluded = true)
- static class ExcludedClass {
-
- }
-
- @Test(excluded = false)
- static class NonExcludedClass {
-
- }
-}
Deleted: trunk/punit.test/src/tests/api/org/punit/method/ByNameMethodFilterTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/ByNameMethodFilterTest.java 2007-06-04 06:37:45 UTC (rev 193)
+++ trunk/punit.test/src/tests/api/org/punit/method/ByNameMethodFilterTest.java 2007-06-04 06:52:38 UTC (rev 194)
@@ -1,55 +0,0 @@
-/* (C) Copyright 2007, by Andrew Zhang */
-
-package tests.api.org.punit.method;
-
-import java.lang.reflect.*;
-
-import junit.framework.*;
-
-import org.punit.runner.*;
-import org.punit.util.*;
-
-public class ByNameMethodFilterTest extends TestCase {
- AnnotationFilter _filter = new AnnotationFilter();
-
- public void testIsTestMethod() {
- Method method;
- method = ReflectionUtil.getMethod(getClass(), "test1", new Class[] {}); //$NON-NLS-1$
- assertTrue(_filter.isTestMethod(method));
-
- method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
- assertFalse(_filter.isTestMethod(method));
- }
-
- public void testGetCheckMethod() {
- Method method, checkMethod;
- method = ReflectionUtil.getMethod(getClass(), "test1", new Class[] {}); //$NON-NLS-1$
- checkMethod = _filter.getCheckMethod(method);
- assertNull(checkMethod);
-
- method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
- checkMethod = _filter.getCheckMethod(method);
- assertEquals("check__test2", checkMethod.getName()); //$NON-NLS-1$
- }
-
-
- public void test1() {
-
- }
-
- public void _test2() {
-
- }
-
- public void check__test2() {
-
- }
-
- public void _test3() {
-
- }
-
- public void check__test3() {
-
- }
-}
Copied: trunk/punit.test/src/tests/api/org/punit/method/NameConventionFilterTest.java (from rev 193, trunk/punit.test/src/tests/api/org/punit/method/ByNameMethodFilterTest.java)
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/NameConventionFilterTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/method/NameConventionFilterTest.java 2007-06-04 06:52:38 UTC (rev 194)
@@ -0,0 +1,55 @@
+/* (C) Copyright 2007, by Andrew Zhang */
+
+package tests.api.org.punit.method;
+
+import java.lang.reflect.*;
+
+import junit.framework.*;
+
+import org.punit.runner.*;
+import org.punit.util.*;
+
+public class NameConventionFilterTest extends TestCase {
+ AnnotationFilter _filter = new AnnotationFilter();
+
+ public void testIsTestMethod() {
+ Method method;
+ method = ReflectionUtil.getMethod(getClass(), "test1", new Class[] {}); //$NON-NLS-1$
+ assertTrue(_filter.isTestMethod(method));
+
+ method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
+ assertFalse(_filter.isTestMethod(method));
+ }
+
+ public void testGetCheckMethod() {
+ Method method, checkMethod;
+ method = ReflectionUtil.getMethod(getClass(), "test1", new Class[] {}); //$NON-NLS-1$
+ checkMethod = _filter.getCheckMethod(method);
+ assertNull(checkMethod);
+
+ method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
+ checkMethod = _filter.getCheckMethod(method);
+ assertEquals("check__test2", checkMethod.getName()); //$NON-NLS-1$
+ }
+
+
+ public void test1() {
+
+ }
+
+ public void _test2() {
+
+ }
+
+ public void check__test2() {
+
+ }
+
+ public void _test3() {
+
+ }
+
+ public void check__test3() {
+
+ }
+}
Modified: trunk/punit.test/src/tests/api/org/punit/method/builder/MethodBuilderTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/builder/MethodBuilderTest.java 2007-06-04 06:37:45 UTC (rev 193)
+++ trunk/punit.test/src/tests/api/org/punit/method/builder/MethodBuilderTest.java 2007-06-04 06:52:38 UTC (rev 194)
@@ -19,7 +19,7 @@
_builder.setMethodFilter(new NameConventionFilter());
}
- public void testAddInterfaces() {
+ public void testAnnotationFilter() {
_builder.setMethodFilter(new AnnotationFilter());
Object[] methods = _builder.buildTestMethods(TestInterfaceImpl1.class)
.toArray();
Deleted: trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestMethodBuilderTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestMethodBuilderTest.java 2007-06-04 06:37:45 UTC (rev 193)
+++ trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestMethodBuilderTest.java 2007-06-04 06:52:38 UTC (rev 194)
@@ -1,50 +0,0 @@
-package tests.api.org.punit.method.builder;
-
-import junit.framework.*;
-
-import org.punit.method.builder.*;
-import org.punit.runner.*;
-
-import tests.api.org.punit.testclasses.*;
-import tests.util.*;
-
-public class PUnitTestMethodBuilderTest extends TestCase {
- private MethodBuilderImpl _builder;
-
- protected void setUp() throws Exception {
- _builder = new MethodBuilderImpl();
- _builder.setMethodFilter(new NameConventionFilter());
- }
-
- public void testBuildTestMethods1() {
- Object[] methods = _builder.buildTestMethods(TestClass1.class)
- .toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArrayContent(new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
- "testa", "testb" }, names); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBuildTestMethods_SubClass() {
- Object[] methods = _builder.buildTestMethods(SubTestClass.class)
- .toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArrayContent(new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
- "testa", "testb" }, names); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBuildTestMethods2() {
- Object[] methods = _builder.buildTestMethods(TestClass2.class)
- .toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArrayContent(names, new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
- "testa", "testb" }); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBuildTestMethods3() {
- Object[] methods = _builder.buildTestMethods(TestClass3.class)
- .toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArray(names, new String[] { "test1", "test2", "testa", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "testb" }); //$NON-NLS-1$
- }
-}
Deleted: trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestSuiteBuilderTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestSuiteBuilderTest.java 2007-06-04 06:37:45 UTC (rev 193)
+++ trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestSuiteBuilderTest.java 2007-06-04 06:52:38 UTC (rev 194)
@@ -1,66 +0,0 @@
-package tests.api.org.punit.method.builder;
-
-import junit.framework.*;
-
-import org.punit.suite.builder.*;
-
-import tests.api.org.punit.testclasses.*;
-import tests.util.*;
-
-public class PUnitTestSuiteBuilderTest extends TestCase {
- private TestSuiteBuilderImpl _testSuiteBuidler;
-
- protected void setUp() throws Exception {
- _testSuiteBuidler = new TestSuiteBuilderImpl();
- }
-
- public void testBuildTestClasses1() {
- Object[] classes = _testSuiteBuidler.buildTestClasses(TestClass1.class);
- AssertUtil.assertArray(classes, new Class[] { TestClass1.class });
- }
-
- public void testBuildTestClasses2() {
- Object[] classes = _testSuiteBuidler.buildTestClasses(TestSuite1.class);
- Class[] expectedClasses = new Class[] { TestClass1.class,
- TestClass2.class, TestClass3.class };
-
- assertEquals(expectedClasses.length + 2, classes.length); // suite labels
-
- TestSuiteLabel label = (TestSuiteLabel) classes[0];
- assertSame(TestSuite1.class, label.suite().getClass());
- assertTrue(label.isStart());
-
- label = (TestSuiteLabel) classes[classes.length - 1];
- assertSame(TestSuite1.class, label.suite().getClass());
- assertFalse(label.isStart());
-
- AssertUtil.assertArrayContains(classes, expectedClasses);
- }
-
- public void testBuildTestClasses3() {
- Object[] classes = _testSuiteBuidler.buildTestClasses(TestSuite2.class);
- Class[] expectedClasses = new Class[] { TestClass4.class,
- TestClass1.class, TestClass2.class, TestClass3.class, TestClass5.class };
-
- assertEquals(expectedClasses.length + 4, classes.length); // suite labels
-
- TestSuiteLabel label = (TestSuiteLabel) classes[0];
- assertSame(TestSuite2.class, label.suite().getClass());
- assertTrue(label.isStart());
-
- label = (TestSuiteLabel) classes[classes.length - 1];
- assertSame(TestSuite2.class, label.suite().getClass());
- assertFalse(label.isStart());
-
- label = (TestSuiteLabel) classes[2];
- assertSame(TestSuite1.class, label.suite().getClass());
- assertTrue(label.isStart());
-
- label = (TestSuiteLabel) classes[6];
- assertSame(TestSuite1.class, label.suite().getClass());
- assertFalse(label.isStart());
-
- AssertUtil.assertArrayContains(classes, expectedClasses);
- }
-
-}
Copied: trunk/punit.test/src/tests/api/org/punit/method/builder/TestMethodBuilderTest.java (from rev 193, trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestMethodBuilderTest.java)
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/builder/TestMethodBuilderTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/method/builder/TestMethodBuilderTest.java 2007-06-04 06:52:38 UTC (rev 194)
@@ -0,0 +1,50 @@
+package tests.api.org.punit.method.builder;
+
+import junit.framework.*;
+
+import org.punit.method.builder.*;
+import org.punit.runner.*;
+
+import tests.api.org.punit.testclasses.*;
+import tests.util.*;
+
+public class TestMethodBuilderTest extends TestCase {
+ private MethodBuilderImpl _builder;
+
+ protected void setUp() throws Exception {
+ _builder = new MethodBuilderImpl();
+ _builder.setMethodFilter(new NameConventionFilter());
+ }
+
+ public void testBuildTestMethods1() {
+ Object[] methods = _builder.buildTestMethods(TestClass1.class)
+ .toArray();
+ String[] names = TestUtil.toMethodNameArray(methods);
+ AssertUtil.assertArrayContent(new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
+ "testa", "testb" }, names); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBuildTestMethods_SubClass() {
+ Object[] methods = _builder.buildTestMethods(SubTestClass.class)
+ .toArray();
+ String[] names = TestUtil.toMethodNameArray(methods);
+ AssertUtil.assertArrayContent(new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
+ "testa", "testb" }, names); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBuildTestMethods2() {
+ Object[] methods = _builder.buildTestMethods(TestClass2.class)
+ .toArray();
+ String[] names = TestUtil.toMethodNameArray(methods);
+ AssertUtil.assertArrayContent(names, new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
+ "testa", "testb" }); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBuildTestMethods3() {
+ Object[] methods = _builder.buildTestMethods(TestClass3.class)
+ .toArray();
+ String[] names = TestUtil.toMethodNameArray(methods);
+ AssertUtil.assertArray(names, new String[] { "test1", "test2", "testa", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "testb" }); //$NON-NLS-1$
+ }
+}
Copied: trunk/punit.test/src/tests/api/org/punit/method/builder/TestSuiteBuilderTest.java (from rev 181, trunk/punit.test/src/tests/api/org/punit/method/builder/PUnitTestSuiteBuilderTest.java)
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/builder/TestSuiteBuilderTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/method/builder/TestSuiteBuilderTest.java 2007-06-04 06:52:38 UTC (rev 194)
@@ -0,0 +1,102 @@
+package tests.api.org.punit.method.builder;
+
+import junit.framework.*;
+
+import org.punit.runner.*;
+import org.punit.suite.builder.*;
+
+import tests.api.org.punit.testclasses.*;
+import tests.util.*;
+
+public class TestSuiteBuilderTest extends TestCase {
+ private TestSuiteBuilderImpl _testSuiteBuidler;
+
+ protected void setUp() throws Exception {
+ _testSuiteBuidler = new TestSuiteBuilderImpl();
+ _testSuiteBuidler.setFilter(new NameConventionFilter());
+ }
+
+ public void testBuildExcludedTestClasses1() {
+ _testSuiteBuidler.setFilter(new AnnotationFilter());
+ Object[] classes = _testSuiteBuidler.buildTestClasses(ExcludedTestClass1.class);
+ AssertUtil.assertArray(classes, new Class[] { });
+ }
+
+ public void testBuildTestClasses1() {
+ Object[] classes = _testSuiteBuidler.buildTestClasses(TestClass1.class);
+ AssertUtil.assertArray(classes, new Class[] { TestClass1.class });
+ }
+
+ public void testBuildTestSuite1() {
+ Object[] classes = _testSuiteBuidler.buildTestClasses(TestSuite1.class);
+ Class[] expectedClasses = new Class[] { TestClass1.class,
+ TestClass2.class, TestClass3.class };
+
+ assertEquals(expectedClasses.length + 2, classes.length); // suite labels
+
+ TestSuiteLabel label = (TestSuiteLabel) classes[0];
+ assertSame(TestSuite1.class, label.suite().getClass());
+ assertTrue(label.isStart());
+
+ label = (TestSuiteLabel) classes[classes.length - 1];
+ assertSame(TestSuite1.class, label.suite().getClass());
+ assertFalse(label.isStart());
+
+ AssertUtil.assertArrayContains(classes, expectedClasses);
+ }
+
+ public void testBuildTestSuite2() {
+ Object[] classes = _testSuiteBuidler.buildTestClasses(TestSuite2.class);
+ Class[] expectedClasses = new Class[] { ExcludedTestClass1.class, TestClass4.class,
+ TestClass1.class, TestClass2.class, TestClass3.class, TestClass5.class };
+
+ assertEquals(expectedClasses.length + 4, classes.length); // suite labels
+
+ TestSuiteLabel label = (TestSuiteLabel) classes[0];
+ assertSame(TestSuite2.class, label.suite().getClass());
+ assertTrue(label.isStart());
+
+ label = (TestSuiteLabel) classes[classes.length - 1];
+ assertSame(TestSuite2.class, label.suite().getClass());
+ assertFalse(label.isStart());
+
+ label = (TestSuiteLabel) classes[3];
+ assertSame(TestSuite1.class, label.suite().getClass());
+ assertTrue(label.isStart());
+
+ label = (TestSuiteLabel) classes[7];
+ assertSame(TestSuite1.class, label.suite().getClass());
+ assertFalse(label.isStart());
+
+ AssertUtil.assertArrayContains(classes, expectedClasses);
+ }
+
+ public void testBuildTestSuite2ByAnnotationFilter() {
+ _testSuiteBuidler.setFilter(new AnnotationFilter());
+ Object[] classes = _testSuiteBuidler.buildTestClasses(TestSuite2.class);
+ Class[] expectedClasses = new Class[] { TestClass4.class,
+ TestClass1.class, TestClass2.class, TestClass3.class, TestClass5.class };
+
+ assertEquals(expectedClasses.length + 4, classes.length); // suite labels
+
+ TestSuiteLabel label = (TestSuiteLabel) classes[0];
+ assertSame(TestSuite2.class, label.suite().getClass());
+ assertTrue(label.isStart());
+
+ label = (TestSuiteLabel) classes[classes.length - 1];
+ assertSame(TestSuite2.class, label.suite().getClass());
+ assertFalse(label.isStart());
+
+ label = (TestSuiteLabel) classes[2];
+ assertSame(TestSuite1.class, label.suite().getClass());
+ assertTrue(label.isStart());
+
+ label = (TestSuiteLabel) classes[6];
+ assertSame(TestSuite1.class, label.suite().getClass());
+ assertFalse(label.isStart());
+
+ AssertUtil.assertArrayContains(classes, expectedClasses);
+ }
+
+
+}
Added: trunk/punit.test/src/tests/api/org/punit/testclasses/ExcludedTestClass1.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/testclasses/ExcludedTestClass1.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/testclasses/ExcludedTestClass1.java 2007-06-04 06:52:38 UTC (rev 194)
@@ -0,0 +1,53 @@
+package tests.api.org.punit.testclasses;
+
+import org.punit.annotation.*;
+import org.punit.type.*;
+
+import tests.util.*;
+
+@Test(excluded = true)
+public class ExcludedTestClass1 {
+ public void test1() {
+ TestUtil.doSomething();
+ }
+
+ public void test1i(int i) {
+ TestUtil.doSomething();
+ }
+
+ public void test2() {
+ TestUtil.doSomething();
+ }
+
+ public void testa() {
+ TestUtil.doSomething();
+ }
+
+ public void testb() {
+ TestUtil.doSomething();
+ }
+
+ public void _testc() {
+ TestUtil.doSomething();
+ }
+
+ void testd() {
+ TestUtil.doSomething();
+ }
+
+ private void teste() {
+ TestUtil.doSomething();
+ }
+
+ public static void testf() {
+ TestUtil.doSomething();
+ }
+
+ public void testParam(Parameter p) {
+ TestUtil.doSomething();
+ }
+
+ public void testParamI(Parameter p, int i) {
+ TestUtil.doSomething();
+ }
+}
\ No newline at end of file
Modified: trunk/punit.test/src/tests/api/org/punit/testclasses/TestSuite2.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/testclasses/TestSuite2.java 2007-06-04 06:37:45 UTC (rev 193)
+++ trunk/punit.test/src/tests/api/org/punit/testclasses/TestSuite2.java 2007-06-04 06:52:38 UTC (rev 194)
@@ -2,7 +2,7 @@
public class TestSuite2 implements org.punit.type.PUnitTestSuite {
public Class[] testSuite() {
- return new Class[] { TestClass4.class, TestSuite1.class,
+ return new Class[] { ExcludedTestClass1.class, TestClass4.class, TestSuite1.class,
TestClass5.class,
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2007-06-04 06:57:11
|
Revision: 195
http://p-unit.svn.sourceforge.net/p-unit/?rev=195&view=rev
Author: zhanghuangzhu
Date: 2007-06-03 23:57:12 -0700 (Sun, 03 Jun 2007)
Log Message:
-----------
Andrew Zhang: refactored name.
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
Added Paths:
-----------
trunk/punit.test/src/tests/api/org/punit/builder/suite/
trunk/punit.test/src/tests/api/org/punit/builder/suite/TestSuiteBuilderTest.java
trunk/punit.test/src/tests/api/org/punit/runner/AnnotationFilterTest.java
trunk/punit.test/src/tests/api/org/punit/runner/NameConventionFilterTest.java
trunk/punit.test/src/tests/api/org/punit/suite/
Removed Paths:
-------------
trunk/punit.test/src/tests/api/org/punit/method/AnnotationFilterTest.java
trunk/punit.test/src/tests/api/org/punit/method/NameConventionFilterTest.java
trunk/punit.test/src/tests/api/org/punit/method/builder/MethodBuilderTest.java
trunk/punit.test/src/tests/api/org/punit/method/builder/TestSuiteBuilderTest.java
Modified: trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2007-06-04 06:52:38 UTC (rev 194)
+++ trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2007-06-04 06:57:12 UTC (rev 195)
@@ -2,6 +2,7 @@
import junit.framework.*;
import tests.api.org.punit.assertion.*;
+import tests.api.org.punit.builder.suite.*;
import tests.api.org.punit.exception.*;
import tests.api.org.punit.method.*;
import tests.api.org.punit.method.builder.*;
@@ -36,7 +37,6 @@
ConcurrentExceptionTest.class,
LoggerUtilTest.class,
MemoryWatcherTest.class,
- MethodBuilderTest.class,
ConcurrentRunnerTest.class,
StreamLoggerTest.class,
ExecutorPoolTest.class,
Copied: trunk/punit.test/src/tests/api/org/punit/builder/suite/TestSuiteBuilderTest.java (from rev 194, trunk/punit.test/src/tests/api/org/punit/method/builder/TestSuiteBuilderTest.java)
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/builder/suite/TestSuiteBuilderTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/builder/suite/TestSuiteBuilderTest.java 2007-06-04 06:57:12 UTC (rev 195)
@@ -0,0 +1,102 @@
+package tests.api.org.punit.builder.suite;
+
+import junit.framework.*;
+
+import org.punit.runner.*;
+import org.punit.suite.builder.*;
+
+import tests.api.org.punit.testclasses.*;
+import tests.util.*;
+
+public class TestSuiteBuilderTest extends TestCase {
+ private TestSuiteBuilderImpl _testSuiteBuidler;
+
+ protected void setUp() throws Exception {
+ _testSuiteBuidler = new TestSuiteBuilderImpl();
+ _testSuiteBuidler.setFilter(new NameConventionFilter());
+ }
+
+ public void testBuildExcludedTestClasses1() {
+ _testSuiteBuidler.setFilter(new AnnotationFilter());
+ Object[] classes = _testSuiteBuidler.buildTestClasses(ExcludedTestClass1.class);
+ AssertUtil.assertArray(classes, new Class[] { });
+ }
+
+ public void testBuildTestClasses1() {
+ Object[] classes = _testSuiteBuidler.buildTestClasses(TestClass1.class);
+ AssertUtil.assertArray(classes, new Class[] { TestClass1.class });
+ }
+
+ public void testBuildTestSuite1() {
+ Object[] classes = _testSuiteBuidler.buildTestClasses(TestSuite1.class);
+ Class[] expectedClasses = new Class[] { TestClass1.class,
+ TestClass2.class, TestClass3.class };
+
+ assertEquals(expectedClasses.length + 2, classes.length); // suite labels
+
+ TestSuiteLabel label = (TestSuiteLabel) classes[0];
+ assertSame(TestSuite1.class, label.suite().getClass());
+ assertTrue(label.isStart());
+
+ label = (TestSuiteLabel) classes[classes.length - 1];
+ assertSame(TestSuite1.class, label.suite().getClass());
+ assertFalse(label.isStart());
+
+ AssertUtil.assertArrayContains(classes, expectedClasses);
+ }
+
+ public void testBuildTestSuite2() {
+ Object[] classes = _testSuiteBuidler.buildTestClasses(TestSuite2.class);
+ Class[] expectedClasses = new Class[] { ExcludedTestClass1.class, TestClass4.class,
+ TestClass1.class, TestClass2.class, TestClass3.class, TestClass5.class };
+
+ assertEquals(expectedClasses.length + 4, classes.length); // suite labels
+
+ TestSuiteLabel label = (TestSuiteLabel) classes[0];
+ assertSame(TestSuite2.class, label.suite().getClass());
+ assertTrue(label.isStart());
+
+ label = (TestSuiteLabel) classes[classes.length - 1];
+ assertSame(TestSuite2.class, label.suite().getClass());
+ assertFalse(label.isStart());
+
+ label = (TestSuiteLabel) classes[3];
+ assertSame(TestSuite1.class, label.suite().getClass());
+ assertTrue(label.isStart());
+
+ label = (TestSuiteLabel) classes[7];
+ assertSame(TestSuite1.class, label.suite().getClass());
+ assertFalse(label.isStart());
+
+ AssertUtil.assertArrayContains(classes, expectedClasses);
+ }
+
+ public void testBuildTestSuite2ByAnnotationFilter() {
+ _testSuiteBuidler.setFilter(new AnnotationFilter());
+ Object[] classes = _testSuiteBuidler.buildTestClasses(TestSuite2.class);
+ Class[] expectedClasses = new Class[] { TestClass4.class,
+ TestClass1.class, TestClass2.class, TestClass3.class, TestClass5.class };
+
+ assertEquals(expectedClasses.length + 4, classes.length); // suite labels
+
+ TestSuiteLabel label = (TestSuiteLabel) classes[0];
+ assertSame(TestSuite2.class, label.suite().getClass());
+ assertTrue(label.isStart());
+
+ label = (TestSuiteLabel) classes[classes.length - 1];
+ assertSame(TestSuite2.class, label.suite().getClass());
+ assertFalse(label.isStart());
+
+ label = (TestSuiteLabel) classes[2];
+ assertSame(TestSuite1.class, label.suite().getClass());
+ assertTrue(label.isStart());
+
+ label = (TestSuiteLabel) classes[6];
+ assertSame(TestSuite1.class, label.suite().getClass());
+ assertFalse(label.isStart());
+
+ AssertUtil.assertArrayContains(classes, expectedClasses);
+ }
+
+
+}
Deleted: trunk/punit.test/src/tests/api/org/punit/method/AnnotationFilterTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/AnnotationFilterTest.java 2007-06-04 06:52:38 UTC (rev 194)
+++ trunk/punit.test/src/tests/api/org/punit/method/AnnotationFilterTest.java 2007-06-04 06:57:12 UTC (rev 195)
@@ -1,97 +0,0 @@
-/* (C) Copyright 2007, by Andrew Zhang */
-
-package tests.api.org.punit.method;
-
-import java.lang.reflect.*;
-
-import junit.framework.*;
-
-import org.punit.annotation.Test;
-import org.punit.runner.*;
-import org.punit.util.*;
-
-public class AnnotationFilterTest extends TestCase {
- AnnotationFilter _filter = new AnnotationFilter();
-
- public void testIsExcluded() {
- assertTrue(_filter.isExcluded(ExcludedClass.class));
- assertFalse(_filter.isExcluded(NonExcludedClass.class));
- assertFalse(_filter.isExcluded(getClass()));
- }
-
- public void testIsTestMethod() {
- Method method;
- method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
- assertFalse(_filter.isTestMethod(method));
-
- method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
- assertTrue(_filter.isTestMethod(method));
- }
-
- public void testGetCheckMethod() {
- Method method, checkMethod;
- method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
- assertFalse(_filter.isTestMethod(method));
- checkMethod = _filter.getCheckMethod(method);
- assertNull(checkMethod);
-
- method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
- assertTrue(_filter.isTestMethod(method));
- checkMethod = _filter.getCheckMethod(method);
- assertEquals("checkTest2", checkMethod.getName()); //$NON-NLS-1$
-
- method = ReflectionUtil.getMethod(getClass(), "_test3", new Class[] {}); //$NON-NLS-1$
- assertTrue(_filter.isTestMethod(method));
- checkMethod = _filter.getCheckMethod(method);
- assertEquals("check__test3", checkMethod.getName()); //$NON-NLS-1$
- }
-
- public void testGetExpectedException() {
- Method method;
- Class exception;
-
- method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
- exception = _filter.getExpectedException(method);
- assertNull(exception);
-
- method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
- exception = _filter.getExpectedException(method);
- assertSame(NullPointerException.class, exception);
-
- method = ReflectionUtil.getMethod(getClass(), "_test3", new Class[] {}); //$NON-NLS-1$
- exception = _filter.getExpectedException(method);
- assertNull(exception);
- }
-
- public void _test1() {
-
- }
-
- @Test(checkMethod="checkTest2", expected=NullPointerException.class)
- public void _test2() {
-
- }
-
- public void checkTest2() {
-
- }
-
- @Test
- public void _test3() {
-
- }
-
- public void check__test3() {
-
- }
-
- @Test(excluded = true)
- static class ExcludedClass {
-
- }
-
- @Test(excluded = false)
- static class NonExcludedClass {
-
- }
-}
Deleted: trunk/punit.test/src/tests/api/org/punit/method/NameConventionFilterTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/NameConventionFilterTest.java 2007-06-04 06:52:38 UTC (rev 194)
+++ trunk/punit.test/src/tests/api/org/punit/method/NameConventionFilterTest.java 2007-06-04 06:57:12 UTC (rev 195)
@@ -1,55 +0,0 @@
-/* (C) Copyright 2007, by Andrew Zhang */
-
-package tests.api.org.punit.method;
-
-import java.lang.reflect.*;
-
-import junit.framework.*;
-
-import org.punit.runner.*;
-import org.punit.util.*;
-
-public class NameConventionFilterTest extends TestCase {
- AnnotationFilter _filter = new AnnotationFilter();
-
- public void testIsTestMethod() {
- Method method;
- method = ReflectionUtil.getMethod(getClass(), "test1", new Class[] {}); //$NON-NLS-1$
- assertTrue(_filter.isTestMethod(method));
-
- method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
- assertFalse(_filter.isTestMethod(method));
- }
-
- public void testGetCheckMethod() {
- Method method, checkMethod;
- method = ReflectionUtil.getMethod(getClass(), "test1", new Class[] {}); //$NON-NLS-1$
- checkMethod = _filter.getCheckMethod(method);
- assertNull(checkMethod);
-
- method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
- checkMethod = _filter.getCheckMethod(method);
- assertEquals("check__test2", checkMethod.getName()); //$NON-NLS-1$
- }
-
-
- public void test1() {
-
- }
-
- public void _test2() {
-
- }
-
- public void check__test2() {
-
- }
-
- public void _test3() {
-
- }
-
- public void check__test3() {
-
- }
-}
Deleted: trunk/punit.test/src/tests/api/org/punit/method/builder/MethodBuilderTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/builder/MethodBuilderTest.java 2007-06-04 06:52:38 UTC (rev 194)
+++ trunk/punit.test/src/tests/api/org/punit/method/builder/MethodBuilderTest.java 2007-06-04 06:57:12 UTC (rev 195)
@@ -1,60 +0,0 @@
-/* (C) Copyright 2007, by Andrew Zhang */
-
-package tests.api.org.punit.method.builder;
-
-import junit.framework.*;
-
-import org.punit.method.builder.*;
-import org.punit.runner.*;
-
-import tests.api.org.punit.testclasses.*;
-import tests.util.*;
-
-public class MethodBuilderTest extends TestCase {
-
- private MethodBuilderImpl _builder;
-
- public void setUp() {
- _builder = new MethodBuilderImpl();
- _builder.setMethodFilter(new NameConventionFilter());
- }
-
- public void testAnnotationFilter() {
- _builder.setMethodFilter(new AnnotationFilter());
- Object[] methods = _builder.buildTestMethods(TestInterfaceImpl1.class)
- .toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArrayContent(names, new String[] { "method1" }); //$NON-NLS-1$
- }
-
- public void testBuildTestMethods1() {
- Object[] methods = _builder.buildTestMethods(TestClass1.class)
- .toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArrayContains(names, new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
- "testa", "testb" }); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBuildTestMethods_SubClass() {
- Object[] methods = _builder.buildTestMethods(SubTestClass.class).toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArrayContains(names, new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
- "testa", "testb" }); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBuildTestMethods2() {
- Object[] methods = _builder.buildTestMethods(TestClass2.class).toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArrayContent(names, new String[] { "test1", "test2", //$NON-NLS-1$ //$NON-NLS-2$
- "testa", "testb" }); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBuildTestMethods3() {
- Object[] methods = _builder.buildTestMethods(TestClass3.class).toArray();
- String[] names = TestUtil.toMethodNameArray(methods);
- AssertUtil.assertArrayContent(names, new String[] {
- "test1", "test2", "testa", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "testb" }); //$NON-NLS-1$
- }
-
-}
Deleted: trunk/punit.test/src/tests/api/org/punit/method/builder/TestSuiteBuilderTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/builder/TestSuiteBuilderTest.java 2007-06-04 06:52:38 UTC (rev 194)
+++ trunk/punit.test/src/tests/api/org/punit/method/builder/TestSuiteBuilderTest.java 2007-06-04 06:57:12 UTC (rev 195)
@@ -1,102 +0,0 @@
-package tests.api.org.punit.method.builder;
-
-import junit.framework.*;
-
-import org.punit.runner.*;
-import org.punit.suite.builder.*;
-
-import tests.api.org.punit.testclasses.*;
-import tests.util.*;
-
-public class TestSuiteBuilderTest extends TestCase {
- private TestSuiteBuilderImpl _testSuiteBuidler;
-
- protected void setUp() throws Exception {
- _testSuiteBuidler = new TestSuiteBuilderImpl();
- _testSuiteBuidler.setFilter(new NameConventionFilter());
- }
-
- public void testBuildExcludedTestClasses1() {
- _testSuiteBuidler.setFilter(new AnnotationFilter());
- Object[] classes = _testSuiteBuidler.buildTestClasses(ExcludedTestClass1.class);
- AssertUtil.assertArray(classes, new Class[] { });
- }
-
- public void testBuildTestClasses1() {
- Object[] classes = _testSuiteBuidler.buildTestClasses(TestClass1.class);
- AssertUtil.assertArray(classes, new Class[] { TestClass1.class });
- }
-
- public void testBuildTestSuite1() {
- Object[] classes = _testSuiteBuidler.buildTestClasses(TestSuite1.class);
- Class[] expectedClasses = new Class[] { TestClass1.class,
- TestClass2.class, TestClass3.class };
-
- assertEquals(expectedClasses.length + 2, classes.length); // suite labels
-
- TestSuiteLabel label = (TestSuiteLabel) classes[0];
- assertSame(TestSuite1.class, label.suite().getClass());
- assertTrue(label.isStart());
-
- label = (TestSuiteLabel) classes[classes.length - 1];
- assertSame(TestSuite1.class, label.suite().getClass());
- assertFalse(label.isStart());
-
- AssertUtil.assertArrayContains(classes, expectedClasses);
- }
-
- public void testBuildTestSuite2() {
- Object[] classes = _testSuiteBuidler.buildTestClasses(TestSuite2.class);
- Class[] expectedClasses = new Class[] { ExcludedTestClass1.class, TestClass4.class,
- TestClass1.class, TestClass2.class, TestClass3.class, TestClass5.class };
-
- assertEquals(expectedClasses.length + 4, classes.length); // suite labels
-
- TestSuiteLabel label = (TestSuiteLabel) classes[0];
- assertSame(TestSuite2.class, label.suite().getClass());
- assertTrue(label.isStart());
-
- label = (TestSuiteLabel) classes[classes.length - 1];
- assertSame(TestSuite2.class, label.suite().getClass());
- assertFalse(label.isStart());
-
- label = (TestSuiteLabel) classes[3];
- assertSame(TestSuite1.class, label.suite().getClass());
- assertTrue(label.isStart());
-
- label = (TestSuiteLabel) classes[7];
- assertSame(TestSuite1.class, label.suite().getClass());
- assertFalse(label.isStart());
-
- AssertUtil.assertArrayContains(classes, expectedClasses);
- }
-
- public void testBuildTestSuite2ByAnnotationFilter() {
- _testSuiteBuidler.setFilter(new AnnotationFilter());
- Object[] classes = _testSuiteBuidler.buildTestClasses(TestSuite2.class);
- Class[] expectedClasses = new Class[] { TestClass4.class,
- TestClass1.class, TestClass2.class, TestClass3.class, TestClass5.class };
-
- assertEquals(expectedClasses.length + 4, classes.length); // suite labels
-
- TestSuiteLabel label = (TestSuiteLabel) classes[0];
- assertSame(TestSuite2.class, label.suite().getClass());
- assertTrue(label.isStart());
-
- label = (TestSuiteLabel) classes[classes.length - 1];
- assertSame(TestSuite2.class, label.suite().getClass());
- assertFalse(label.isStart());
-
- label = (TestSuiteLabel) classes[2];
- assertSame(TestSuite1.class, label.suite().getClass());
- assertTrue(label.isStart());
-
- label = (TestSuiteLabel) classes[6];
- assertSame(TestSuite1.class, label.suite().getClass());
- assertFalse(label.isStart());
-
- AssertUtil.assertArrayContains(classes, expectedClasses);
- }
-
-
-}
Copied: trunk/punit.test/src/tests/api/org/punit/runner/AnnotationFilterTest.java (from rev 194, trunk/punit.test/src/tests/api/org/punit/method/AnnotationFilterTest.java)
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/runner/AnnotationFilterTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/runner/AnnotationFilterTest.java 2007-06-04 06:57:12 UTC (rev 195)
@@ -0,0 +1,97 @@
+/* (C) Copyright 2007, by Andrew Zhang */
+
+package tests.api.org.punit.runner;
+
+import java.lang.reflect.*;
+
+import junit.framework.*;
+
+import org.punit.annotation.Test;
+import org.punit.runner.*;
+import org.punit.util.*;
+
+public class AnnotationFilterTest extends TestCase {
+ AnnotationFilter _filter = new AnnotationFilter();
+
+ public void testIsExcluded() {
+ assertTrue(_filter.isExcluded(ExcludedClass.class));
+ assertFalse(_filter.isExcluded(NonExcludedClass.class));
+ assertFalse(_filter.isExcluded(getClass()));
+ }
+
+ public void testIsTestMethod() {
+ Method method;
+ method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
+ assertFalse(_filter.isTestMethod(method));
+
+ method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
+ assertTrue(_filter.isTestMethod(method));
+ }
+
+ public void testGetCheckMethod() {
+ Method method, checkMethod;
+ method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
+ assertFalse(_filter.isTestMethod(method));
+ checkMethod = _filter.getCheckMethod(method);
+ assertNull(checkMethod);
+
+ method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
+ assertTrue(_filter.isTestMethod(method));
+ checkMethod = _filter.getCheckMethod(method);
+ assertEquals("checkTest2", checkMethod.getName()); //$NON-NLS-1$
+
+ method = ReflectionUtil.getMethod(getClass(), "_test3", new Class[] {}); //$NON-NLS-1$
+ assertTrue(_filter.isTestMethod(method));
+ checkMethod = _filter.getCheckMethod(method);
+ assertEquals("check__test3", checkMethod.getName()); //$NON-NLS-1$
+ }
+
+ public void testGetExpectedException() {
+ Method method;
+ Class exception;
+
+ method = ReflectionUtil.getMethod(getClass(), "_test1", new Class[] {}); //$NON-NLS-1$
+ exception = _filter.getExpectedException(method);
+ assertNull(exception);
+
+ method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
+ exception = _filter.getExpectedException(method);
+ assertSame(NullPointerException.class, exception);
+
+ method = ReflectionUtil.getMethod(getClass(), "_test3", new Class[] {}); //$NON-NLS-1$
+ exception = _filter.getExpectedException(method);
+ assertNull(exception);
+ }
+
+ public void _test1() {
+
+ }
+
+ @Test(checkMethod="checkTest2", expected=NullPointerException.class)
+ public void _test2() {
+
+ }
+
+ public void checkTest2() {
+
+ }
+
+ @Test
+ public void _test3() {
+
+ }
+
+ public void check__test3() {
+
+ }
+
+ @Test(excluded = true)
+ static class ExcludedClass {
+
+ }
+
+ @Test(excluded = false)
+ static class NonExcludedClass {
+
+ }
+}
Copied: trunk/punit.test/src/tests/api/org/punit/runner/NameConventionFilterTest.java (from rev 194, trunk/punit.test/src/tests/api/org/punit/method/NameConventionFilterTest.java)
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/runner/NameConventionFilterTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/runner/NameConventionFilterTest.java 2007-06-04 06:57:12 UTC (rev 195)
@@ -0,0 +1,55 @@
+/* (C) Copyright 2007, by Andrew Zhang */
+
+package tests.api.org.punit.runner;
+
+import java.lang.reflect.*;
+
+import junit.framework.*;
+
+import org.punit.runner.*;
+import org.punit.util.*;
+
+public class NameConventionFilterTest extends TestCase {
+ AnnotationFilter _filter = new AnnotationFilter();
+
+ public void testIsTestMethod() {
+ Method method;
+ method = ReflectionUtil.getMethod(getClass(), "test1", new Class[] {}); //$NON-NLS-1$
+ assertTrue(_filter.isTestMethod(method));
+
+ method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
+ assertFalse(_filter.isTestMethod(method));
+ }
+
+ public void testGetCheckMethod() {
+ Method method, checkMethod;
+ method = ReflectionUtil.getMethod(getClass(), "test1", new Class[] {}); //$NON-NLS-1$
+ checkMethod = _filter.getCheckMethod(method);
+ assertNull(checkMethod);
+
+ method = ReflectionUtil.getMethod(getClass(), "_test2", new Class[] {}); //$NON-NLS-1$
+ checkMethod = _filter.getCheckMethod(method);
+ assertEquals("check__test2", checkMethod.getName()); //$NON-NLS-1$
+ }
+
+
+ public void test1() {
+
+ }
+
+ public void _test2() {
+
+ }
+
+ public void check__test2() {
+
+ }
+
+ public void _test3() {
+
+ }
+
+ public void check__test3() {
+
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2007-06-16 00:22:00
|
Revision: 219
http://p-unit.svn.sourceforge.net/p-unit/?rev=219&view=rev
Author: zhanghuangzhu
Date: 2007-06-15 17:22:01 -0700 (Fri, 15 Jun 2007)
Log Message:
-----------
Andrew Zhang: removed some warnings.
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/convention/JUnitAnnotationConventionTest.java
trunk/punit.test/src/tests/api/org/punit/method/builder/TestMethodBuilderTest.java
trunk/punit.test/src/tests/api/org/punit/suite/builder/TestSuiteBuilderTest.java
Modified: trunk/punit.test/src/tests/api/org/punit/convention/JUnitAnnotationConventionTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/convention/JUnitAnnotationConventionTest.java 2007-06-15 09:37:08 UTC (rev 218)
+++ trunk/punit.test/src/tests/api/org/punit/convention/JUnitAnnotationConventionTest.java 2007-06-16 00:22:01 UTC (rev 219)
@@ -6,7 +6,6 @@
import junit.framework.*;
-import org.junit.Test;
import org.punit.convention.*;
import org.punit.util.*;
Modified: trunk/punit.test/src/tests/api/org/punit/method/builder/TestMethodBuilderTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/builder/TestMethodBuilderTest.java 2007-06-15 09:37:08 UTC (rev 218)
+++ trunk/punit.test/src/tests/api/org/punit/method/builder/TestMethodBuilderTest.java 2007-06-16 00:22:01 UTC (rev 219)
@@ -4,8 +4,6 @@
import org.punit.convention.*;
import org.punit.method.builder.*;
-import org.punit.runner.*;
-
import tests.api.org.punit.testclasses.*;
import tests.util.*;
Modified: trunk/punit.test/src/tests/api/org/punit/suite/builder/TestSuiteBuilderTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/suite/builder/TestSuiteBuilderTest.java 2007-06-15 09:37:08 UTC (rev 218)
+++ trunk/punit.test/src/tests/api/org/punit/suite/builder/TestSuiteBuilderTest.java 2007-06-16 00:22:01 UTC (rev 219)
@@ -3,7 +3,6 @@
import junit.framework.*;
import org.punit.convention.*;
-import org.punit.runner.*;
import org.punit.suite.builder.*;
import tests.api.org.punit.testclasses.*;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2007-11-27 12:54:55
|
Revision: 256
http://p-unit.svn.sourceforge.net/p-unit/?rev=256&view=rev
Author: zhanghuangzhu
Date: 2007-11-27 04:55:00 -0800 (Tue, 27 Nov 2007)
Log Message:
-----------
az: Added a Message hack, and refactored StreamLogger. Now p-unit is ready for Android!
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/all/PUnitAllTests.java
trunk/punit.test/src/tests/api/org/punit/reporter/stream/StreamLoggerTest.java
Modified: trunk/punit.test/src/tests/api/org/punit/all/PUnitAllTests.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/all/PUnitAllTests.java 2007-11-27 12:54:49 UTC (rev 255)
+++ trunk/punit.test/src/tests/api/org/punit/all/PUnitAllTests.java 2007-11-27 12:55:00 UTC (rev 256)
@@ -6,7 +6,8 @@
public class PUnitAllTests implements TestSuite {
public static void main(String[] args) {
- new SoloRunner().run(PUnitAllTests.class);
+ SoloRunner soloRunner = new SoloRunner();
+ soloRunner.run(PUnitAllTests.class);
}
public Class[] testSuite() {
Modified: trunk/punit.test/src/tests/api/org/punit/reporter/stream/StreamLoggerTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/reporter/stream/StreamLoggerTest.java 2007-11-27 12:54:49 UTC (rev 255)
+++ trunk/punit.test/src/tests/api/org/punit/reporter/stream/StreamLoggerTest.java 2007-11-27 12:55:00 UTC (rev 256)
@@ -1,7 +1,8 @@
package tests.api.org.punit.reporter.stream;
-import java.io.OutputStream;
-import java.io.PrintStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Writer;
import java.util.logging.Level;
import junit.framework.TestCase;
@@ -13,11 +14,11 @@
public class StreamLoggerTest extends TestCase {
ConsoleLogger _logger = new ConsoleLogger();
- private MockPrintStream _mockPrintStream;
+ private MockPrintWriter _mockPrintStream;
protected void setUp() throws Exception {
- _mockPrintStream = new MockPrintStream(System.err);
- _logger.setStream(_mockPrintStream, _mockPrintStream);
+ _mockPrintStream = new MockPrintWriter();
+ _logger.setWriter(new PrintWriter(_mockPrintStream));
}
public void test1() {
@@ -40,8 +41,7 @@
public void testSerializable() throws Exception {
ConsoleLogger logger = (ConsoleLogger) TestUtil.getSerialiableObject(_logger);
- assertSame(System.out, logger.outPrintStream());
- assertSame(System.err, logger.errPrintStream());
+ assertNotNull(logger.writer());
}
private void assertPrinted() {
@@ -52,17 +52,26 @@
assertFalse(_mockPrintStream._printed);
}
- private static class MockPrintStream extends PrintStream {
+ private static class MockPrintWriter extends Writer {
+ public MockPrintWriter() {
+ }
- public boolean _printed;
+ public boolean _printed;
- public MockPrintStream(OutputStream out) {
- super(out);
- }
-
public void print(String s) {
_printed = true;
}
+ public void close() throws IOException {
+
+ }
+
+ public void flush() throws IOException {
+ }
+
+ public void write(char[] arg0, int arg1, int arg2) throws IOException {
+ _printed = true;
+ }
+
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-18 00:54:02
|
Revision: 297
http://p-unit.svn.sourceforge.net/p-unit/?rev=297&view=rev
Author: zhanghuangzhu
Date: 2008-04-17 17:54:09 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
az: simplify test suite builder logic.
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
trunk/punit.test/src/tests/api/org/punit/runner/AbstractRunnerTest.java
Removed Paths:
-------------
trunk/punit.test/src/tests/api/org/punit/suite/builder/
Modified: trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2008-04-18 00:53:53 UTC (rev 296)
+++ trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2008-04-18 00:54:09 UTC (rev 297)
@@ -43,7 +43,6 @@
SoloRunnerTest.class,
StreamLoggerTest.class,
TestMethodBuilderTest.class,
- TestSuiteBuilderTest.class,
TimeWatcherTest.class
};
}
Modified: trunk/punit.test/src/tests/api/org/punit/runner/AbstractRunnerTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/runner/AbstractRunnerTest.java 2008-04-18 00:53:53 UTC (rev 296)
+++ trunk/punit.test/src/tests/api/org/punit/runner/AbstractRunnerTest.java 2008-04-18 00:54:09 UTC (rev 297)
@@ -2,12 +2,11 @@
package tests.api.org.punit.runner;
-import junit.framework.TestCase;
+import junit.framework.*;
-import org.punit.method.builder.MethodBuilderImpl;
-import org.punit.method.runner.SoloMethodRunner;
-import org.punit.runner.AbstractRunner;
-import org.punit.suite.builder.TestSuiteBuilderImpl;
+import org.punit.method.builder.*;
+import org.punit.method.runner.*;
+import org.punit.runner.*;
public class AbstractRunnerTest extends TestCase {
@@ -33,8 +32,7 @@
private static final long serialVersionUID = 1L;
public MockAbstractRunner() {
- super(new TestSuiteBuilderImpl(), new MethodBuilderImpl(),
- new SoloMethodRunner());
+ super(new MethodBuilderImpl(), new SoloMethodRunner());
}
public String punitName() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-18 01:20:23
|
Revision: 300
http://p-unit.svn.sourceforge.net/p-unit/?rev=300&view=rev
Author: zhanghuangzhu
Date: 2008-04-17 18:20:12 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
az: added method info in failure
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
Added Paths:
-----------
trunk/punit.test/src/tests/api/org/punit/reporter/TestResultTest.java
Modified: trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2008-04-18 01:19:53 UTC (rev 299)
+++ trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2008-04-18 01:20:12 UTC (rev 300)
@@ -6,6 +6,7 @@
import tests.api.org.punit.exception.*;
import tests.api.org.punit.method.builder.*;
import tests.api.org.punit.method.runner.*;
+import tests.api.org.punit.reporter.*;
import tests.api.org.punit.reporter.stream.*;
import tests.api.org.punit.runner.*;
import tests.api.org.punit.util.*;
@@ -42,6 +43,7 @@
SoloRunnerTest.class,
StreamLoggerTest.class,
TestMethodBuilderTest.class,
+ TestResultTest.class,
TimeWatcherTest.class
};
}
Added: trunk/punit.test/src/tests/api/org/punit/reporter/TestResultTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/reporter/TestResultTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/reporter/TestResultTest.java 2008-04-18 01:20:12 UTC (rev 300)
@@ -0,0 +1,22 @@
+package tests.api.org.punit.reporter;
+
+import java.lang.reflect.*;
+
+import junit.framework.*;
+
+import org.punit.reporter.*;
+
+public class TestResultTest extends TestCase {
+
+ private org.punit.reporter.TestResult _testResult = new org.punit.reporter.TestResult();
+
+ public void testOnMethodEnd() throws Exception {
+ Method method = getClass().getDeclaredMethod("testOnMethodEnd", new Class [] {});
+ RuntimeException e = new RuntimeException();
+ _testResult.onMethodEnd(method, this, null, e , null);
+ assertEquals(1, _testResult.failures().size());
+ Failure failure = _testResult.failures().get(0);
+ assertSame(e, failure.throwable);
+ assertSame(method, failure.method);
+ }
+}
Property changes on: trunk/punit.test/src/tests/api/org/punit/reporter/TestResultTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-05-28 00:44:39
|
Revision: 311
http://p-unit.svn.sourceforge.net/p-unit/?rev=311&view=rev
Author: zhanghuangzhu
Date: 2008-05-27 17:44:46 -0700 (Tue, 27 May 2008)
Log Message:
-----------
az: applied nested beforeClass/afterClass/setUp/tearDown patch from Chris Wilson.
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/convention/AnnotationFilterTest.java
trunk/punit.test/src/tests/api/org/punit/convention/NameConventionFilterTest.java
trunk/punit.test/src/tests/api/org/punit/runner/ConcurrentRunnerTest.java
trunk/punit.test/src/tests/api/org/punit/testclasses/AnnotationTestClass.java
trunk/punit.test/src/tests/api/org/punit/testclasses/TestClass0.java
Added Paths:
-----------
trunk/punit.test/src/tests/api/org/punit/testclasses/SuperAnnotationTestClass.java
Modified: trunk/punit.test/src/tests/api/org/punit/convention/AnnotationFilterTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/convention/AnnotationFilterTest.java 2008-05-28 00:44:26 UTC (rev 310)
+++ trunk/punit.test/src/tests/api/org/punit/convention/AnnotationFilterTest.java 2008-05-28 00:44:46 UTC (rev 311)
@@ -109,6 +109,23 @@
assertNull(_filter.getAfterClassMethod(TestClass1.class));
}
+ public void testGetNestedBeforeClass() {
+ assertTrue(_filter.getBeforeClassMethod(AnnotationTestClass.class).length == 2);
+
+ }
+
+ public void testGetNestedAfterClass() {
+ assertTrue(_filter.getAfterClassMethod(AnnotationTestClass.class).length == 2);
+ }
+
+ public void testGetNestedSetupMethod() {
+ assertTrue(_filter.getSetUpMethod(AnnotationTestClass.class).length == 2);
+ }
+
+ public void testGetNestedTearDownMethod() {
+ assertTrue(_filter.getTearDownMethod(AnnotationTestClass.class).length == 2);
+ }
+
@Ignore
static class ExcludedClass {
Modified: trunk/punit.test/src/tests/api/org/punit/convention/NameConventionFilterTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/convention/NameConventionFilterTest.java 2008-05-28 00:44:26 UTC (rev 310)
+++ trunk/punit.test/src/tests/api/org/punit/convention/NameConventionFilterTest.java 2008-05-28 00:44:46 UTC (rev 311)
@@ -63,12 +63,12 @@
}
public void testGetBeforeClass() {
- assertEquals("beforeClass", _convention.getBeforeClassMethod(TestClass0.class).getName());
+ assertEquals("beforeClass", _convention.getBeforeClassMethod(TestClass0.class)[0].getName());
assertNull(_convention.getBeforeClassMethod(TestClass1.class));
}
public void testGetAfterClass() {
- assertEquals("afterClass", _convention.getAfterClassMethod(TestClass0.class).getName());
+ assertEquals("afterClass", _convention.getAfterClassMethod(TestClass0.class)[0].getName());
assertNull(_convention.getAfterClassMethod(TestClass1.class));
}
Modified: trunk/punit.test/src/tests/api/org/punit/runner/ConcurrentRunnerTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/runner/ConcurrentRunnerTest.java 2008-05-28 00:44:26 UTC (rev 310)
+++ trunk/punit.test/src/tests/api/org/punit/runner/ConcurrentRunnerTest.java 2008-05-28 00:44:46 UTC (rev 311)
@@ -22,12 +22,15 @@
public class ConcurrentRunnerTest extends TestCase {
- private ConcurrentRunner _runner = new ConcurrentRunner();
+ private ConcurrentRunner _runner;
public static void main(String[] args) {
new SoloRunner().run(ConcurrentRunnerTest.class);
}
-
+
+ public void setUp() {
+ _runner = new ConcurrentRunner();
+ }
public void testMain() {
ConcurrentRunner.main(new String[] { TestSuiteClass.class.getName() });
}
Modified: trunk/punit.test/src/tests/api/org/punit/testclasses/AnnotationTestClass.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/testclasses/AnnotationTestClass.java 2008-05-28 00:44:26 UTC (rev 310)
+++ trunk/punit.test/src/tests/api/org/punit/testclasses/AnnotationTestClass.java 2008-05-28 00:44:46 UTC (rev 311)
@@ -8,7 +8,7 @@
import org.punit.runner.*;
@Test(concurrentCount=5)
-public class AnnotationTestClass {
+public class AnnotationTestClass extends SuperAnnotationTestClass {
public static void main(String[] args) {
SoloRunner soloRunner = new SoloRunner();
@@ -126,5 +126,6 @@
Assert.assertTrue(_setUp);
Assert.assertTrue(_tearDown);
+ SuperAnnotationTestClass.assertTestClassRun();
}
}
Added: trunk/punit.test/src/tests/api/org/punit/testclasses/SuperAnnotationTestClass.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/testclasses/SuperAnnotationTestClass.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/testclasses/SuperAnnotationTestClass.java 2008-05-28 00:44:46 UTC (rev 311)
@@ -0,0 +1,54 @@
+package tests.api.org.punit.testclasses;
+
+import junit.framework.*;
+
+import org.punit.annotation.*;
+import org.punit.annotation.Test;
+
+@Test(concurrentCount=5)
+public class SuperAnnotationTestClass {
+
+ private static boolean _beforeClass;
+ private static boolean _afterClass;
+ private static boolean _setUp;
+ private static boolean _tearDown;
+
+ public static void reset() {
+ _setUp = false;
+ _tearDown = false;
+ _beforeClass = false;
+ _afterClass = false;
+ }
+
+ @SuppressWarnings("unused")
+ @BeforeClass
+ private static void beforeClassMethod() {
+ _beforeClass = true;
+ }
+
+ @SuppressWarnings("unused")
+ @AfterClass
+ private static void afterClassMethod() {
+ _afterClass = true;
+ }
+
+ @SuppressWarnings("unused")
+ @Before
+ private void before() {
+ _setUp = true;
+ }
+
+ @SuppressWarnings("unused")
+ @After
+ private void after() {
+ _tearDown = true;
+ }
+
+ public static void assertTestClassRun() {
+ Assert.assertTrue(_beforeClass);
+ Assert.assertTrue(_afterClass);
+
+ Assert.assertTrue(_setUp);
+ Assert.assertTrue(_tearDown);
+ }
+}
\ No newline at end of file
Property changes on: trunk/punit.test/src/tests/api/org/punit/testclasses/SuperAnnotationTestClass.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/punit.test/src/tests/api/org/punit/testclasses/TestClass0.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/testclasses/TestClass0.java 2008-05-28 00:44:26 UTC (rev 310)
+++ trunk/punit.test/src/tests/api/org/punit/testclasses/TestClass0.java 2008-05-28 00:44:46 UTC (rev 311)
@@ -37,10 +37,12 @@
}
private void setUp() {
+ System.err.println("setup");
_setUp = true;
}
private void tearDown() {
+ System.err.println("tearDown");
_tearDown = true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cu...@us...> - 2008-06-10 08:22:49
|
Revision: 317
http://p-unit.svn.sourceforge.net/p-unit/?rev=317&view=rev
Author: cuvavu
Date: 2008-06-10 01:22:52 -0700 (Tue, 10 Jun 2008)
Log Message:
-----------
Making the concurrentRunner run before and after stuff in the same thread as the actual test.
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/method/runner/AbstractMethodRunnerTest.java
trunk/punit.test/src/tests/api/org/punit/runner/ConcurrentRunnerTest.java
Added Paths:
-----------
trunk/punit.test/src/tests/api/org/punit/testclasses/BeforeAndAfterConcurrentTestClass.java
Modified: trunk/punit.test/src/tests/api/org/punit/method/runner/AbstractMethodRunnerTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/runner/AbstractMethodRunnerTest.java 2008-05-28 12:46:18 UTC (rev 316)
+++ trunk/punit.test/src/tests/api/org/punit/method/runner/AbstractMethodRunnerTest.java 2008-06-10 08:22:52 UTC (rev 317)
@@ -67,7 +67,7 @@
public void testRun_MultipleExceptions() {
resetRunFlag();
_methodRunner.run(new TestMultiException(), getMethod(TestMultiException.class, "test"), new Object[] {});
- Assert.assertEquals(NullPointerException.class, _mockEvenListener.throwable);
+ Assert.assertEquals(IllegalStateException.class, _mockEvenListener.throwable);
}
private void resetRunFlag() {
@@ -109,9 +109,18 @@
private static class MockMethodRunner extends AbstractMethodRunner {
public boolean isInvoked;
- protected void runImpl() throws Throwable {
+ protected void runImpl( boolean doNormalSetupAndTeardown ) throws Throwable {
isInvoked = true;
- super.runMethod();
+ try {
+ if (doNormalSetupAndTeardown) {
+ setUp();
+ }
+ super.runMethod();
+ } finally {
+ if (doNormalSetupAndTeardown) {
+ tearDown();
+ }
+ }
}
}
Modified: trunk/punit.test/src/tests/api/org/punit/runner/ConcurrentRunnerTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/runner/ConcurrentRunnerTest.java 2008-05-28 12:46:18 UTC (rev 316)
+++ trunk/punit.test/src/tests/api/org/punit/runner/ConcurrentRunnerTest.java 2008-06-10 08:22:52 UTC (rev 317)
@@ -9,9 +9,11 @@
import org.punit.convention.AnnotationConvention;
import org.punit.events.*;
import org.punit.runner.ConcurrentRunner;
+import org.punit.runner.ExecutorPoolImpl;
import org.punit.runner.SoloRunner;
import tests.api.org.punit.testclasses.AnnotationTestClass;
+import tests.api.org.punit.testclasses.BeforeAndAfterConcurrentTestClass;
import tests.api.org.punit.testclasses.ConcurrentParameterizedTestClass;
import tests.api.org.punit.testclasses.ConcurrentTestClass;
import tests.api.org.punit.testclasses.LoopTestClass;
@@ -31,70 +33,81 @@
public void setUp() {
_runner = new ConcurrentRunner();
}
- public void testMain() {
- ConcurrentRunner.main(new String[] { TestSuiteClass.class.getName() });
- }
-
- public void testRun() {
- _runner.run(TestSuiteClass.class);
- }
-
- public void testRunLoopTest() {
- LoopTestClass.reset();
- _runner.run(LoopTestClass.class);
- LoopTestClass.assertTestClassRun();
- }
-
- public void testRunConcurrent() {
- ConcurrentTestClass.reset();
- _runner.run(ConcurrentTestClass.class);
- assertConcurrentTestClassRun();
- }
-
- public void testRunTest() {
- TestClass0.reset();
- _runner.run(TestClass0.class);
- TestClass0.assertTestClassRun();
- }
-
- public void testRunAnnotationTest() {
- AnnotationTestClass.reset();
+// public void testMain() {
+// ConcurrentRunner.main(new String[] { TestSuiteClass.class.getName() });
+// }
+//
+// public void testRun() {
+// _runner.run(TestSuiteClass.class);
+// }
+//
+// public void testRunLoopTest() {
+// LoopTestClass.reset();
+// _runner.run(LoopTestClass.class);
+// LoopTestClass.assertTestClassRun();
+// }
+//
+// public void testRunConcurrent() {
+// ConcurrentTestClass.reset();
+// _runner.run(ConcurrentTestClass.class);
+// assertConcurrentTestClassRun();
+// }
+//
+// public void testRunTest() {
+// TestClass0.reset();
+// _runner.run(TestClass0.class);
+// TestClass0.assertTestClassRun();
+// }
+//
+// public void testRunAnnotationTest() {
+// AnnotationTestClass.reset();
+// _runner.setConvention(new AnnotationConvention());
+// _runner.run(AnnotationTestClass.class);
+// AnnotationTestClass.assertTestClassRun();
+// }
+//
+// public void testRunPUnitTest() {
+// TestClass3.reset();
+// _runner.run(TestClass3.class);
+// TestClass3.assertTestClassRun();
+// }
+//
+// public void testRunParameterized() throws Exception {
+// ConcurrentParameterizedTestClass.reset();
+// _runner.run(ConcurrentParameterizedTestClass.class);
+// ConcurrentParameterizedTestClass.assertTestClassRun();
+// }
+//
+// public void testRunTestSuite() {
+// ConcurrentTestClass.reset();
+// TestClass0.reset();
+// TestClass3.reset();
+// _runner.run(TestSuiteClass.class);
+// assertConcurrentTestClassRun();
+// TestClass0.assertTestClassRun();
+// TestClass3.assertTestClassRun();
+// }
+//
+// public void testSerializable() throws Exception {
+// _runner.addEventListener(new MockEventListener());
+// List<EventListener> expectedListeners = _runner.eventListeners();
+// ConcurrentRunner runner = (ConcurrentRunner) TestUtil
+// .getSerialiableObject(_runner);
+// List<EventListener> eventListeners = runner.eventListeners();
+// assertEquals(expectedListeners.size(), eventListeners.size());
+// }
+
+ /**
+ * Test to check that the before and after methods run in the same thread as the methods
+ */
+ public void testBeforeAndAfterThreads() throws Exception {
+ _runner = new ConcurrentRunner(1);
+// _runner.setExecutorPool(new ExecutorPoolImpl(2));
_runner.setConvention(new AnnotationConvention());
- _runner.run(AnnotationTestClass.class);
- AnnotationTestClass.assertTestClassRun();
+ _runner.run(BeforeAndAfterConcurrentTestClass.class);
+ assertEquals(_runner.testResult().failures().size(), 0);
}
- public void testRunPUnitTest() {
- TestClass3.reset();
- _runner.run(TestClass3.class);
- TestClass3.assertTestClassRun();
- }
-
- public void testRunParameterized() throws Exception {
- ConcurrentParameterizedTestClass.reset();
- _runner.run(ConcurrentParameterizedTestClass.class);
- ConcurrentParameterizedTestClass.assertTestClassRun();
- }
-
- public void testRunTestSuite() {
- ConcurrentTestClass.reset();
- TestClass0.reset();
- TestClass3.reset();
- _runner.run(TestSuiteClass.class);
- assertConcurrentTestClassRun();
- TestClass0.assertTestClassRun();
- TestClass3.assertTestClassRun();
- }
-
- public void testSerializable() throws Exception {
- _runner.addEventListener(new MockEventListener());
- List<EventListener> expectedListeners = _runner.eventListeners();
- ConcurrentRunner runner = (ConcurrentRunner) TestUtil
- .getSerialiableObject(_runner);
- List<EventListener> eventListeners = runner.eventListeners();
- assertEquals(expectedListeners.size(), eventListeners.size());
- }
-
private void assertConcurrentTestClassRun() {
ConcurrentTestClass test = new ConcurrentTestClass();
assertEquals(test.concurrentCount(), ConcurrentTestClass.value);
Added: trunk/punit.test/src/tests/api/org/punit/testclasses/BeforeAndAfterConcurrentTestClass.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/testclasses/BeforeAndAfterConcurrentTestClass.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/testclasses/BeforeAndAfterConcurrentTestClass.java 2008-06-10 08:22:52 UTC (rev 317)
@@ -0,0 +1,32 @@
+package tests.api.org.punit.testclasses;
+
+import org.punit.annotation.After;
+import org.punit.annotation.Before;
+import org.punit.annotation.Test;
+
+import static junit.framework.Assert.*;
+
+import tests.util.*;
+
+public class BeforeAndAfterConcurrentTestClass {
+
+ private int value1 = 0;
+
+ @Before
+ public void before() {
+ value1 = 5;
+ }
+
+ @Test
+ public synchronized void one() {
+ TestUtil.doSomething();
+ value1 += 5;
+ assertEquals(10, value1);
+ }
+
+ @After
+ public void after() {
+ value1 += 5;
+ assertEquals(15, value1);
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2007-05-31 07:41:54
|
Revision: 182
http://p-unit.svn.sourceforge.net/p-unit/?rev=182&view=rev
Author: zhanghuangzhu
Date: 2007-05-31 00:41:56 -0700 (Thu, 31 May 2007)
Log Message:
-----------
Andrew Zhang: refactored test package name.
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
Added Paths:
-----------
trunk/punit.test/src/tests/api/org/punit/method/runner/
trunk/punit.test/src/tests/api/org/punit/method/runner/AbstractTestMethodRunnerTest.java
Removed Paths:
-------------
trunk/punit.test/src/tests/api/org/punit/method/runner/AbstractTestMethodRunnerTest.java
trunk/punit.test/src/tests/api/org/punit/runner/method/
Modified: trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2007-05-31 07:38:11 UTC (rev 181)
+++ trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2007-05-31 07:41:56 UTC (rev 182)
@@ -5,9 +5,9 @@
import tests.api.org.punit.exception.*;
import tests.api.org.punit.method.*;
import tests.api.org.punit.method.builder.*;
+import tests.api.org.punit.method.runner.*;
import tests.api.org.punit.reporter.stream.*;
import tests.api.org.punit.runner.*;
-import tests.api.org.punit.runner.method.*;
import tests.api.org.punit.util.*;
import tests.api.org.punit.watcher.*;
import extension.tests.api.org.punit.reporter.chart.*;
Copied: trunk/punit.test/src/tests/api/org/punit/method/runner (from rev 177, trunk/punit.test/src/tests/api/org/punit/runner/method)
Deleted: trunk/punit.test/src/tests/api/org/punit/method/runner/AbstractTestMethodRunnerTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/runner/method/AbstractTestMethodRunnerTest.java 2007-05-31 06:11:41 UTC (rev 177)
+++ trunk/punit.test/src/tests/api/org/punit/method/runner/AbstractTestMethodRunnerTest.java 2007-05-31 07:41:56 UTC (rev 182)
@@ -1,63 +0,0 @@
-package tests.api.org.punit.runner.method;
-
-import java.util.*;
-
-import junit.framework.*;
-
-import org.punit.annotation.Test.*;
-import org.punit.method.runner.*;
-import org.punit.util.*;
-import org.punit.watcher.*;
-
-import tests.api.org.punit.testclasses.*;
-
-public class AbstractTestMethodRunnerTest extends TestCase {
- private MockTestMethodRunnerTest _mockRunner = new MockTestMethodRunnerTest();
-
- public void testWatchers() {
- List watchers = _mockRunner.watchers();
- assertEquals(1, watchers.size()); // time, and memory watchers
-
- _mockRunner.removeTimeWatcher();
- watchers = _mockRunner.watchers();
- assertEquals(0, watchers.size());
-
- _mockRunner.addWatcher(new TimeWatcher());
- watchers = _mockRunner.watchers();
- assertEquals(1, watchers.size());
- }
-
- public void testRunMethod() throws Throwable {
- _mockRunner.testRunMethod1();
- }
-
- static class MockTestMethodRunnerTest extends AbstractMethodRunner {
-
- private static final long serialVersionUID = 1L;
-
- public void testRunMethod1() throws Throwable {
- AnnotationTestClass.reset();
- this._method = ReflectionUtil.getMethod(AnnotationTestClass.class,"test1", new Class[]{}); //$NON-NLS-1$
- this._params = new Object[] {};
- this._testInstance = new AnnotationTestClass();
- this._expectedException = null;
- super.runMethod();
- Assert.assertTrue(AnnotationTestClass._test1);
- }
-
- public void testRunMethod2() throws Throwable {
- AnnotationTestClass.reset();
- this._method = ReflectionUtil.getMethod(AnnotationTestClass.class,"_testException", new Class[]{}); //$NON-NLS-1$
- this._params = new Object[] {};
- this._testInstance = new AnnotationTestClass();
- this._expectedException = NoException.class;
- super.runMethod();
- Assert.assertTrue(AnnotationTestClass._testException);
- }
-
- protected void runImpl() throws Throwable {
- throw new UnsupportedOperationException();
- }
-
- }
-}
Copied: trunk/punit.test/src/tests/api/org/punit/method/runner/AbstractTestMethodRunnerTest.java (from rev 181, trunk/punit.test/src/tests/api/org/punit/runner/method/AbstractTestMethodRunnerTest.java)
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/method/runner/AbstractTestMethodRunnerTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/method/runner/AbstractTestMethodRunnerTest.java 2007-05-31 07:41:56 UTC (rev 182)
@@ -0,0 +1,89 @@
+package tests.api.org.punit.method.runner;
+
+import java.util.*;
+
+import junit.framework.*;
+import junit.framework.Assert;
+
+import org.punit.assertion.*;
+import org.punit.method.runner.*;
+import org.punit.util.*;
+import org.punit.watcher.*;
+
+import tests.api.org.punit.testclasses.*;
+
+public class AbstractTestMethodRunnerTest extends TestCase {
+ private MockTestMethodRunnerTest _mockRunner = new MockTestMethodRunnerTest();
+
+ public void testWatchers() {
+ List watchers = _mockRunner.watchers();
+ assertEquals(1, watchers.size()); // time, and memory watchers
+
+ _mockRunner.removeTimeWatcher();
+ watchers = _mockRunner.watchers();
+ assertEquals(0, watchers.size());
+
+ _mockRunner.addWatcher(new TimeWatcher());
+ watchers = _mockRunner.watchers();
+ assertEquals(1, watchers.size());
+ }
+
+ public void testRunMethod1() throws Throwable {
+ _mockRunner.testRunMethod1();
+ }
+
+ public void testRunMethod2() throws Throwable {
+ _mockRunner.testRunMethod2();
+ }
+
+ public void testRunMethod3() throws Throwable {
+ _mockRunner.testRunMethod3();
+ }
+
+ static class MockTestMethodRunnerTest extends AbstractMethodRunner {
+
+ private static final long serialVersionUID = 1L;
+
+ public void testRunMethod1() throws Throwable {
+ AnnotationTestClass.reset();
+ this._method = ReflectionUtil.getMethod(AnnotationTestClass.class,
+ "test1", new Class[] {}); //$NON-NLS-1$
+ this._params = new Object[] {};
+ this._testInstance = new AnnotationTestClass();
+ this._expectedException = null;
+ super.runMethod();
+ Assert.assertTrue(AnnotationTestClass._test1);
+ }
+
+ public void testRunMethod2() throws Throwable {
+ AnnotationTestClass.reset();
+ this._method = ReflectionUtil.getMethod(AnnotationTestClass.class,
+ "_testException", new Class[] {}); //$NON-NLS-1$
+ this._params = new Object[] {};
+ this._testInstance = new AnnotationTestClass();
+ this._expectedException = null;
+ org.punit.assertion.Assert.assertException(NullPointerException.class, new CodeRunner(){
+ public void run() throws Throwable {
+ runMethod();
+ }
+ });
+ Assert.assertTrue(AnnotationTestClass._testException);
+ }
+
+ public void testRunMethod3() throws Throwable {
+ AnnotationTestClass.reset();
+ this._method = ReflectionUtil.getMethod(AnnotationTestClass.class,
+ "_testException", new Class[] {}); //$NON-NLS-1$
+ this._params = new Object[] {};
+ this._testInstance = new AnnotationTestClass();
+ this._expectedException = NullPointerException.class;
+ super.runMethod();
+ Assert.assertTrue(AnnotationTestClass._testException);
+ }
+
+ protected void runImpl() throws Throwable {
+ throw new UnsupportedOperationException();
+ }
+
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|