diff -wrc junit3.7a/junit/awtui/TestRunner.java temp folder/junit3.7/junit/awtui/TestRunner.java *** junit3.7a/junit/awtui/TestRunner.java Mon Sep 17 16:48:01 2001 --- temp folder/junit3.7/junit/awtui/TestRunner.java Mon Sep 17 17:41:34 2001 *************** *** 124,132 **** mb.add(createJUnitMenu()); } protected TestResult createTestResult() { ! TestResult result = new TestResult(); ! Assert.setResult(result); ! return result; } protected Frame createUI(String suiteName) { --- 124,130 ---- mb.add(createJUnitMenu()); } protected TestResult createTestResult() { ! return new TestResult(); } protected Frame createUI(String suiteName) { diff -wrc junit3.7a/junit/framework/Assert.java temp folder/junit3.7/junit/framework/Assert.java *** junit3.7a/junit/framework/Assert.java Mon Sep 17 16:54:05 2001 --- temp folder/junit3.7/junit/framework/Assert.java Mon Sep 17 17:41:35 2001 *************** *** 2,49 **** /** * A set of assert methods. - * Modified to allow for multiple failures by Shane Celis */ public class Assert { - - /** - * Needed for doing multiple failures in one test. - **/ - private static TestResult result; - - /** - * The test that will be calling the asserts (usually just - * this, by virtue of extension a la TestCase) - **/ - private final Test test; /** ! * Protect constructor since it is a static only class (not any more) */ ! public Assert() { ! this.test = (Test) this; ! } ! ! /** ! * Public constructor for performing asserts on tests which don't extend ! * Assert. ! **/ ! public Assert(Test test) { ! this.test = test; ! } ! ! private Test getTest() { ! if (test == null) { ! throw new NullPointerException(); ! } ! return test; } /** * Asserts that a condition is true. If it isn't it throws * an AssertionFailedError with the given message. * @deprecated use assertTrue */ ! public void assert(String message, boolean condition) { if (!condition) fail(message); } --- 2,21 ---- /** * A set of assert methods. */ public class Assert { /** ! * Protect constructor since it is a static only class */ ! protected Assert() { } /** * Asserts that a condition is true. If it isn't it throws * an AssertionFailedError with the given message. * @deprecated use assertTrue */ ! static public void assert(String message, boolean condition) { if (!condition) fail(message); } *************** *** 53,59 **** * @deprecated use assertTrue * */ ! public void assert(boolean condition) { assert(null, condition); } --- 25,31 ---- * @deprecated use assertTrue * */ ! static public void assert(boolean condition) { assert(null, condition); } *************** *** 61,67 **** * Asserts that a condition is true. If it isn't it throws * an AssertionFailedError with the given message. */ ! public void assertTrue(String message, boolean condition) { if (!condition) fail(message); } --- 33,39 ---- * Asserts that a condition is true. If it isn't it throws * an AssertionFailedError with the given message. */ ! static public void assertTrue(String message, boolean condition) { if (!condition) fail(message); } *************** *** 69,110 **** * Asserts that a condition is true. If it isn't it throws * an AssertionFailedError. */ ! public void assertTrue(boolean condition) { assertTrue(null, condition); } /** * Fails a test with the given message. */ ! public void fail(String message) { ! TestResult result = getResult(); ! if (result != null) { ! //New behavior (multiple failures per test) ! result.addFailure(getTest(), ! new AssertionFailedError(message)); ! } else { ! //Old behavior (one failure per test) throw new AssertionFailedError(message); } - } - - public static TestResult getResult() { - return result; - } - - public static void setResult(TestResult result) { - Assert.result = result; - } /** * Fails a test with no message. */ ! public void fail() { fail(null); } /** * Asserts that two objects are equal. If they are not * an AssertionFailedError is thrown. */ ! public void assertEquals(String message, Object expected, Object actual) { if (expected == null && actual == null) return; if (expected != null && expected.equals(actual)) --- 41,66 ---- * Asserts that a condition is true. If it isn't it throws * an AssertionFailedError. */ ! static public void assertTrue(boolean condition) { assertTrue(null, condition); } /** * Fails a test with the given message. */ ! static public void fail(String message) { throw new AssertionFailedError(message); } /** * Fails a test with no message. */ ! static public void fail() { fail(null); } /** * Asserts that two objects are equal. If they are not * an AssertionFailedError is thrown. */ ! static public void assertEquals(String message, Object expected, Object actual) { if (expected == null && actual == null) return; if (expected != null && expected.equals(actual)) *************** *** 115,128 **** * Asserts that two objects are equal. If they are not * an AssertionFailedError is thrown. */ ! public void assertEquals(Object expected, Object actual) { assertEquals(null, expected, actual); } /** * Asserts that two doubles are equal concerning a delta. If the expected * value is infinity then the delta value is ignored. */ ! public void assertEquals(String message, double expected, double actual, double delta) { // handle infinity specially since subtracting to infinite values gives NaN and the // the following test fails if (Double.isInfinite(expected)) { --- 71,84 ---- * Asserts that two objects are equal. If they are not * an AssertionFailedError is thrown. */ ! static public void assertEquals(Object expected, Object actual) { assertEquals(null, expected, actual); } /** * Asserts that two doubles are equal concerning a delta. If the expected * value is infinity then the delta value is ignored. */ ! static public void assertEquals(String message, double expected, double actual, double delta) { // handle infinity specially since subtracting to infinite values gives NaN and the // the following test fails if (Double.isInfinite(expected)) { *************** *** 135,148 **** * Asserts that two doubles are equal concerning a delta. If the expected * value is infinity then the delta value is ignored. */ ! public void assertEquals(double expected, double actual, double delta) { assertEquals(null, expected, actual, delta); } /** * Asserts that two floats are equal concerning a delta. If the expected * value is infinity then the delta value is ignored. */ ! public void assertEquals(String message, float expected, float actual, float delta) { // handle infinity specially since subtracting to infinite values gives NaN and the // the following test fails if (Float.isInfinite(expected)) { --- 91,104 ---- * Asserts that two doubles are equal concerning a delta. If the expected * value is infinity then the delta value is ignored. */ ! static public void assertEquals(double expected, double actual, double delta) { assertEquals(null, expected, actual, delta); } /** * Asserts that two floats are equal concerning a delta. If the expected * value is infinity then the delta value is ignored. */ ! static public void assertEquals(String message, float expected, float actual, float delta) { // handle infinity specially since subtracting to infinite values gives NaN and the // the following test fails if (Float.isInfinite(expected)) { *************** *** 155,264 **** * Asserts that two floats are equal concerning a delta. If the expected * value is infinity then the delta value is ignored. */ ! public void assertEquals(float expected, float actual, float delta) { assertEquals(null, expected, actual, delta); } /** * Asserts that two longs are equal. */ ! public void assertEquals(String message, long expected, long actual) { assertEquals(message, new Long(expected), new Long(actual)); } /** * Asserts that two longs are equal. */ ! public void assertEquals(long expected, long actual) { assertEquals(null, expected, actual); } /** * Asserts that two booleans are equal. */ ! public void assertEquals(String message, boolean expected, boolean actual) { assertEquals(message, new Boolean(expected), new Boolean(actual)); } /** * Asserts that two booleans are equal. */ ! public void assertEquals(boolean expected, boolean actual) { assertEquals(null, expected, actual); } /** * Asserts that two bytes are equal. */ ! public void assertEquals(String message, byte expected, byte actual) { assertEquals(message, new Byte(expected), new Byte(actual)); } /** * Asserts that two bytes are equal. */ ! public void assertEquals(byte expected, byte actual) { assertEquals(null, expected, actual); } /** * Asserts that two chars are equal. */ ! public void assertEquals(String message, char expected, char actual) { assertEquals(message, new Character(expected), new Character(actual)); } /** * Asserts that two chars are equal. */ ! public void assertEquals(char expected, char actual) { assertEquals(null, expected, actual); } /** * Asserts that two shorts are equal. */ ! public void assertEquals(String message, short expected, short actual) { assertEquals(message, new Short(expected), new Short(actual)); } /** * Asserts that two shorts are equal. */ ! public void assertEquals(short expected, short actual) { assertEquals(null, expected, actual); } /** * Asserts that two ints are equal. */ ! public void assertEquals(String message, int expected, int actual) { assertEquals(message, new Integer(expected), new Integer(actual)); } /** * Asserts that two ints are equal. */ ! public void assertEquals(int expected, int actual) { assertEquals(null, expected, actual); } /** * Asserts that an object isn't null. */ ! public void assertNotNull(Object object) { assertNotNull(null, object); } /** * Asserts that an object isn't null. */ ! public void assertNotNull(String message, Object object) { assertTrue(message, object != null); } /** * Asserts that an object is null. */ ! public void assertNull(Object object) { assertNull(null, object); } /** * Asserts that an object is null. */ ! public void assertNull(String message, Object object) { assertTrue(message, object == null); } /** * Asserts that two objects refer to the same object. If they are not * an AssertionFailedError is thrown. */ ! public void assertSame(String message, Object expected, Object actual) { if (expected == actual) return; failNotSame(message, expected, actual); --- 111,220 ---- * Asserts that two floats are equal concerning a delta. If the expected * value is infinity then the delta value is ignored. */ ! static public void assertEquals(float expected, float actual, float delta) { assertEquals(null, expected, actual, delta); } /** * Asserts that two longs are equal. */ ! static public void assertEquals(String message, long expected, long actual) { assertEquals(message, new Long(expected), new Long(actual)); } /** * Asserts that two longs are equal. */ ! static public void assertEquals(long expected, long actual) { assertEquals(null, expected, actual); } /** * Asserts that two booleans are equal. */ ! static public void assertEquals(String message, boolean expected, boolean actual) { assertEquals(message, new Boolean(expected), new Boolean(actual)); } /** * Asserts that two booleans are equal. */ ! static public void assertEquals(boolean expected, boolean actual) { assertEquals(null, expected, actual); } /** * Asserts that two bytes are equal. */ ! static public void assertEquals(String message, byte expected, byte actual) { assertEquals(message, new Byte(expected), new Byte(actual)); } /** * Asserts that two bytes are equal. */ ! static public void assertEquals(byte expected, byte actual) { assertEquals(null, expected, actual); } /** * Asserts that two chars are equal. */ ! static public void assertEquals(String message, char expected, char actual) { assertEquals(message, new Character(expected), new Character(actual)); } /** * Asserts that two chars are equal. */ ! static public void assertEquals(char expected, char actual) { assertEquals(null, expected, actual); } /** * Asserts that two shorts are equal. */ ! static public void assertEquals(String message, short expected, short actual) { assertEquals(message, new Short(expected), new Short(actual)); } /** * Asserts that two shorts are equal. */ ! static public void assertEquals(short expected, short actual) { assertEquals(null, expected, actual); } /** * Asserts that two ints are equal. */ ! static public void assertEquals(String message, int expected, int actual) { assertEquals(message, new Integer(expected), new Integer(actual)); } /** * Asserts that two ints are equal. */ ! static public void assertEquals(int expected, int actual) { assertEquals(null, expected, actual); } /** * Asserts that an object isn't null. */ ! static public void assertNotNull(Object object) { assertNotNull(null, object); } /** * Asserts that an object isn't null. */ ! static public void assertNotNull(String message, Object object) { assertTrue(message, object != null); } /** * Asserts that an object is null. */ ! static public void assertNull(Object object) { assertNull(null, object); } /** * Asserts that an object is null. */ ! static public void assertNull(String message, Object object) { assertTrue(message, object == null); } /** * Asserts that two objects refer to the same object. If they are not * an AssertionFailedError is thrown. */ ! static public void assertSame(String message, Object expected, Object actual) { if (expected == actual) return; failNotSame(message, expected, actual); *************** *** 267,284 **** * Asserts that two objects refer to the same object. If they are not * the same an AssertionFailedError is thrown. */ ! public void assertSame(Object expected, Object actual) { assertSame(null, expected, actual); } ! private void failNotEquals(String message, Object expected, Object actual) { String formatted= ""; if (message != null) formatted= message+" "; fail(formatted+"expected:<"+expected+"> but was:<"+actual+">"); } ! private void failNotSame(String message, Object expected, Object actual) { String formatted= ""; if (message != null) formatted= message+" "; --- 223,240 ---- * Asserts that two objects refer to the same object. If they are not * the same an AssertionFailedError is thrown. */ ! static public void assertSame(Object expected, Object actual) { assertSame(null, expected, actual); } ! static private void failNotEquals(String message, Object expected, Object actual) { String formatted= ""; if (message != null) formatted= message+" "; fail(formatted+"expected:<"+expected+"> but was:<"+actual+">"); } ! static private void failNotSame(String message, Object expected, Object actual) { String formatted= ""; if (message != null) formatted= message+" "; diff -wrc junit3.7a/junit/framework/TestResult.java temp folder/junit3.7/junit/framework/TestResult.java *** junit3.7a/junit/framework/TestResult.java Mon Sep 17 17:23:30 2001 --- temp folder/junit3.7/junit/framework/TestResult.java Mon Sep 17 17:41:35 2001 *************** *** 1,8 **** package junit.framework; import java.util.Vector; - import java.util.Set; - import java.util.HashSet; import java.util.Enumeration; /** --- 1,6 ---- *************** *** 18,24 **** protected Vector fFailures; protected Vector fErrors; protected Vector fListeners; - protected Set fTestFailures; protected int fRunTests; private boolean fStop; --- 16,21 ---- *************** *** 26,32 **** fFailures= new Vector(); fErrors= new Vector(); fListeners= new Vector(); - fTestFailures = new HashSet(); // should synchronize maybe? fRunTests= 0; fStop= false; } --- 23,28 ---- *************** *** 45,51 **** * caused the failure. */ public synchronized void addFailure(Test test, AssertionFailedError t) { - fTestFailures.add(test); fFailures.addElement(new TestFailure(test, t)); for (Enumeration e= cloneListeners().elements(); e.hasMoreElements(); ) { ((TestListener)e.nextElement()).addFailure(test, t); --- 41,46 ---- *************** *** 93,102 **** * Gets the number of detected failures. */ public synchronized int failureCount() { ! // trims the failure count down to the number of tests that ! // have failed and not just the number of ! return fTestFailures.size(); ! //return fFailures.size(); } /** * Returns an Enumeration for the failures --- 88,94 ---- * Gets the number of detected failures. */ public synchronized int failureCount() { ! return fFailures.size(); } /** * Returns an Enumeration for the failures diff -wrc junit3.7a/junit/samples/SimpleTest.java temp folder/junit3.7/junit/samples/SimpleTest.java *** junit3.7a/junit/samples/SimpleTest.java Mon Sep 17 15:48:07 2001 --- temp folder/junit3.7/junit/samples/SimpleTest.java Mon May 21 10:18:56 2001 *************** *** 58,66 **** assertEquals("Size", 12, 13); assertEquals("Capacity", 12.0, 11.99, 0.0); } - public void testMultipleFailures() { - fail("failing once"); - fail("failing twice"); - fail("failing once, again"); - } } --- 58,61 ---- diff -wrc junit3.7a/junit/swingui/TestRunner.java temp folder/junit3.7/junit/swingui/TestRunner.java *** junit3.7a/junit/swingui/TestRunner.java Mon Sep 17 16:50:29 2001 --- temp folder/junit3.7/junit/swingui/TestRunner.java Mon Sep 17 17:41:35 2001 *************** *** 375,383 **** } protected TestResult createTestResult() { ! TestResult result = new TestResult(); ! Assert.setResult(result); ! return result; } protected JFrame createUI(String suiteName) { --- 375,381 ---- } protected TestResult createTestResult() { ! return new TestResult(); } protected JFrame createUI(String suiteName) { diff -wrc junit3.7a/junit/textui/TestRunner.java temp folder/junit3.7/junit/textui/TestRunner.java *** junit3.7a/junit/textui/TestRunner.java Mon Sep 17 15:40:11 2001 --- temp folder/junit3.7/junit/textui/TestRunner.java Mon Sep 17 17:41:35 2001 *************** *** 24,31 **** *

* TestRunner prints a trace as the tests are executed followed by a * summary at the end. - * - * Modified to allow for multiple Test Failures by Shane Celis */ public class TestRunner extends BaseTestRunner { PrintStream fWriter= System.out; --- 24,29 ---- *************** *** 66,74 **** * Creates the TestResult to be used for the test run. */ protected TestResult createTestResult() { ! TestResult result = new TestResult(); ! Assert.setResult(result); ! return result; } public TestResult doRun(Test suite, boolean wait) { --- 64,70 ---- * Creates the TestResult to be used for the test run. */ protected TestResult createTestResult() { ! return new TestResult(); } public TestResult doRun(Test suite, boolean wait) {