You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(80) |
Nov
(42) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(11) |
Feb
(50) |
Mar
(70) |
Apr
(102) |
May
(28) |
Jun
(45) |
Jul
(14) |
Aug
(75) |
Sep
(17) |
Oct
(15) |
Nov
(11) |
Dec
(4) |
2003 |
Jan
(16) |
Feb
(19) |
Mar
(21) |
Apr
(20) |
May
(29) |
Jun
(7) |
Jul
(5) |
Aug
|
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(3) |
2004 |
Jan
(5) |
Feb
(4) |
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
(1) |
Jul
(7) |
Aug
(1) |
Sep
(6) |
Oct
(6) |
Nov
(1) |
Dec
(2) |
2005 |
Jan
(4) |
Feb
(4) |
Mar
(15) |
Apr
(1) |
May
|
Jun
(4) |
Jul
(6) |
Aug
(6) |
Sep
|
Oct
(4) |
Nov
(2) |
Dec
(4) |
2006 |
Jan
|
Feb
(91) |
Mar
(47) |
Apr
(7) |
May
(4) |
Jun
(9) |
Jul
(1) |
Aug
|
Sep
(5) |
Oct
(36) |
Nov
(95) |
Dec
(12) |
2007 |
Jan
(11) |
Feb
(31) |
Mar
(45) |
Apr
(11) |
May
(9) |
Jun
(1) |
Jul
(146) |
Aug
(15) |
Sep
|
Oct
(3) |
Nov
(6) |
Dec
(1) |
2008 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(2) |
Aug
(19) |
Sep
(1) |
Oct
(10) |
Nov
|
Dec
(8) |
2009 |
Jan
(3) |
Feb
(1) |
Mar
(4) |
Apr
(8) |
May
(5) |
Jun
(4) |
Jul
(2) |
Aug
(1) |
Sep
(2) |
Oct
(13) |
Nov
(13) |
Dec
(4) |
2010 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
(2) |
May
|
Jun
(1) |
Jul
(3) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2011 |
Jan
(1) |
Feb
(4) |
Mar
(3) |
Apr
(4) |
May
|
Jun
(12) |
Jul
(16) |
Aug
(4) |
Sep
(7) |
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
From: David S. <ds...@us...> - 2006-02-15 22:55:50
|
Update of /cvsroot/junit/junit/junit4.0/doc/faq In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/junit4.0/doc/faq Added Files: faq.htm Log Message: Merged with branch, Kent will make final changes and launch. --- NEW FILE: faq.htm --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>JUnit FAQ</title> <style type="text/css"> body { font-style: normal; font-weight: normal; margin-left: 10pt; margin-right: 10pt; } a { text-decoration: none; } [...2301 lines suppressed...] similar to JUnit for other languages?</b> </p> <p> XProgramming.com maintains a complete list of available <a href="http://www.xprogramming.com/software.htm">xUnit testing frameworks</a>. </p> </li> </ol> <br/> <div align="right"> <a href="http://validator.w3.org/check?uri=referer"> <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a> </div> </body> </html> |
From: David S. <ds...@us...> - 2006-02-15 22:55:50
|
Update of /cvsroot/junit/junit/junit4.0/org/junit/samples/money In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/junit4.0/org/junit/samples/money Added Files: MoneyTest.java Log Message: Merged with branch, Kent will make final changes and launch. --- NEW FILE: MoneyTest.java --- package org.junit.samples.money; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import junit.framework.JUnit4TestAdapter; import junit.samples.money.IMoney; import junit.samples.money.Money; import junit.samples.money.MoneyBag; import org.junit.Before; import org.junit.Test; public class MoneyTest { private Money f12CHF; private Money f14CHF; private Money f7USD; private Money f21USD; private IMoney fMB1; private IMoney fMB2; public static junit.framework.Test suite() { return new JUnit4TestAdapter(MoneyTest.class); } @Before public void setUp() { f12CHF= new Money(12, "CHF"); f14CHF= new Money(14, "CHF"); f7USD= new Money( 7, "USD"); f21USD= new Money(21, "USD"); fMB1= MoneyBag.create(f12CHF, f7USD); fMB2= MoneyBag.create(f14CHF, f21USD); } @Test public void testBagMultiply() { // {[12 CHF][7 USD]} *2 == {[24 CHF][14 USD]} IMoney expected= MoneyBag.create(new Money(24, "CHF"), new Money(14, "USD")); assertEquals(expected, fMB1.multiply(2)); assertEquals(fMB1, fMB1.multiply(1)); assertTrue(fMB1.multiply(0).isZero()); } @Test public void testBagNegate() { // {[12 CHF][7 USD]} negate == {[-12 CHF][-7 USD]} IMoney expected= MoneyBag.create(new Money(-12, "CHF"), new Money(-7, "USD")); assertEquals(expected, fMB1.negate()); } @Test public void testBagSimpleAdd() { // {[12 CHF][7 USD]} + [14 CHF] == {[26 CHF][7 USD]} IMoney expected= MoneyBag.create(new Money(26, "CHF"), new Money(7, "USD")); assertEquals(expected, fMB1.add(f14CHF)); } @Test public void testBagSubtract() { // {[12 CHF][7 USD]} - {[14 CHF][21 USD] == {[-2 CHF][-14 USD]} IMoney expected= MoneyBag.create(new Money(-2, "CHF"), new Money(-14, "USD")); assertEquals(expected, fMB1.subtract(fMB2)); } @Test public void testBagSumAdd() { // {[12 CHF][7 USD]} + {[14 CHF][21 USD]} == {[26 CHF][28 USD]} IMoney expected= MoneyBag.create(new Money(26, "CHF"), new Money(28, "USD")); assertEquals(expected, fMB1.add(fMB2)); } @Test public void testIsZero() { assertTrue(fMB1.subtract(fMB1).isZero()); assertTrue(MoneyBag.create(new Money (0, "CHF"), new Money (0, "USD")).isZero()); } @Test public void testMixedSimpleAdd() { // [12 CHF] + [7 USD] == {[12 CHF][7 USD]} IMoney expected= MoneyBag.create(f12CHF, f7USD); assertEquals(expected, f12CHF.add(f7USD)); } @Test public void testBagNotEquals() { IMoney bag= MoneyBag.create(f12CHF, f7USD); assertFalse(bag.equals(new Money(12, "DEM").add(f7USD))); } @Test public void testMoneyBagEquals() { assertTrue(!fMB1.equals(null)); assertEquals(fMB1, fMB1); IMoney equal= MoneyBag.create(new Money(12, "CHF"), new Money(7, "USD")); assertTrue(fMB1.equals(equal)); assertTrue(!fMB1.equals(f12CHF)); assertTrue(!f12CHF.equals(fMB1)); assertTrue(!fMB1.equals(fMB2)); } @Test public void testMoneyBagHash() { IMoney equal= MoneyBag.create(new Money(12, "CHF"), new Money(7, "USD")); assertEquals(fMB1.hashCode(), equal.hashCode()); } @Test public void testMoneyEquals() { assertTrue(!f12CHF.equals(null)); Money equalMoney= new Money(12, "CHF"); assertEquals(f12CHF, f12CHF); assertEquals(f12CHF, equalMoney); assertEquals(f12CHF.hashCode(), equalMoney.hashCode()); assertTrue(!f12CHF.equals(f14CHF)); } @Test public void zeroMoniesAreEqualRegardlessOfCurrency() { Money zeroDollars= new Money(0, "USD"); Money zeroFrancs= new Money(0, "CHF"); assertEquals(zeroDollars, zeroFrancs); assertEquals(zeroDollars.hashCode(), zeroFrancs.hashCode()); } @Test public void testMoneyHash() { assertTrue(!f12CHF.equals(null)); Money equal= new Money(12, "CHF"); assertEquals(f12CHF.hashCode(), equal.hashCode()); } @Test public void testSimplify() { IMoney money= MoneyBag.create(new Money(26, "CHF"), new Money(28, "CHF")); assertEquals(new Money(54, "CHF"), money); } @Test public void testNormalize2() { // {[12 CHF][7 USD]} - [12 CHF] == [7 USD] Money expected= new Money(7, "USD"); assertEquals(expected, fMB1.subtract(f12CHF)); } @Test public void testNormalize3() { // {[12 CHF][7 USD]} - {[12 CHF][3 USD]} == [4 USD] IMoney ms1= MoneyBag.create(new Money(12, "CHF"), new Money(3, "USD")); Money expected= new Money(4, "USD"); assertEquals(expected, fMB1.subtract(ms1)); } @Test public void testNormalize4() { // [12 CHF] - {[12 CHF][3 USD]} == [-3 USD] IMoney ms1= MoneyBag.create(new Money(12, "CHF"), new Money(3, "USD")); Money expected= new Money(-3, "USD"); assertEquals(expected, f12CHF.subtract(ms1)); } @Test public void testPrint() { assertEquals("[12 CHF]", f12CHF.toString()); } @Test public void testSimpleAdd() { // [12 CHF] + [14 CHF] == [26 CHF] Money expected= new Money(26, "CHF"); assertEquals(expected, f12CHF.add(f14CHF)); } @Test public void testSimpleBagAdd() { // [14 CHF] + {[12 CHF][7 USD]} == {[26 CHF][7 USD]} IMoney expected= MoneyBag.create(new Money(26, "CHF"), new Money(7, "USD")); assertEquals(expected, f14CHF.add(fMB1)); } @Test public void testSimpleMultiply() { // [14 CHF] *2 == [28 CHF] Money expected= new Money(28, "CHF"); assertEquals(expected, f14CHF.multiply(2)); } @Test public void testSimpleNegate() { // [14 CHF] negate == [-14 CHF] Money expected= new Money(-14, "CHF"); assertEquals(expected, f14CHF.negate()); } @Test public void testSimpleSubtract() { // [14 CHF] - [12 CHF] == [2 CHF] Money expected= new Money(2, "CHF"); assertEquals(expected, f14CHF.subtract(f12CHF)); } } |
From: David S. <ds...@us...> - 2006-02-15 22:55:50
|
Update of /cvsroot/junit/junit/junit/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/junit/tests Modified Files: WasRun.java Log Message: Merged with branch, Kent will make final changes and launch. Index: WasRun.java =================================================================== RCS file: /cvsroot/junit/junit/junit/tests/WasRun.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- WasRun.java 9 Sep 2004 21:53:57 -0000 1.4 +++ WasRun.java 15 Feb 2006 22:55:41 -0000 1.5 @@ -8,6 +8,7 @@ */ public class WasRun extends TestCase { public boolean fWasRun= false; + @Override protected void runTest() { fWasRun= true; } |
From: David S. <ds...@us...> - 2006-02-15 22:55:50
|
Update of /cvsroot/junit/junit/org/junit/samples/money In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/org/junit/samples/money Added Files: MoneyTest.java Log Message: Merged with branch, Kent will make final changes and launch. |
From: David S. <ds...@us...> - 2006-02-15 22:55:50
|
Update of /cvsroot/junit/junit/junit4.0/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/junit4.0/doc Added Files: index.htm Log Message: Merged with branch, Kent will make final changes and launch. --- NEW FILE: index.htm --- <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="Author" content="Erich Gamma"> <title>JUnit Documentation</title> </head> <body> <h1> <font color="#33FF33">J</font><font color="#CC0000">U</font>nit Documentation</h1> <p> Kent Beck, Erich Gamma, David Saff</p> <hr WIDTH="100%"> We have just begun documenting the new JUnit 4 architecture. The <a href="cookbook/cookbook.htm">cookbook</a> has already been updated. <hr WIDTH="100%"> </body> </html> |
From: David S. <ds...@us...> - 2006-02-15 22:55:49
|
Update of /cvsroot/junit/junit/.settings In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/.settings Added Files: org.eclipse.jdt.ui.prefs org.eclipse.jdt.core.prefs Log Message: Merged with branch, Kent will make final changes and launch. |
From: David S. <ds...@us...> - 2006-02-15 22:55:49
|
Update of /cvsroot/junit/junit/junit4.0/doc/cookbook In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/junit4.0/doc/cookbook Added Files: logo.gif cookbook.htm Log Message: Merged with branch, Kent will make final changes and launch. --- NEW FILE: logo.gif --- GIF89a& ¿õºÑjÒ)w½z'Χ3¥R-JnÛ¥b¼Eº.W½{Ùö;Õ£UÁ~ÿD;¶q@ --- NEW FILE: cookbook.htm --- <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="Author" content="Erich Gamma"> <title>JUnit Cookbook</title> </head> <body> <h1> <font color="#33FF33">J</font><font color="#CC0000">U</font>nit Cookbook</h1> <p> Kent Beck, Erich Gamma</p> <hr WIDTH="100%"> <br>Here is a short cookbook showing you the steps you can follow in writing and organizing your own tests using JUnit. <h2> Simple Test Case</h2> How do you write testing code? <p>The simplest way is as an expression in a debugger. You can change debug expressions without recompiling, and you can wait to decide what to write until you have seen the running objects. You can also write test expressions as statements which print to the standard output stream. Both styles of tests are limited because they require human judgment to analyze their results. Also, they don't compose nicely- you can only execute one debug expression at a time and a program with too many print statements causes the dreaded "Scroll Blindness". <p>JUnit tests do not require human judgment to interpret, and it is easy to run many of them at the same time. When you need to test something, here is what you do: <ol> <li> Annotate a method with @org.junit.Test <li> When you want to check a value, import org.junit.Assert.* statically, call <tt>assertTrue</tt>() and pass a boolean that is true if the test succeeds</li> </ol> For example, to test that the sum of two Moneys with the same currency contains a value which is the sum of the values of the two Moneys, write: <blockquote> <pre><tt>@Test public void simpleAdd() { Money m12CHF= new Money(12, "CHF"); Money m14CHF= new Money(14, "CHF"); Money expected= new Money(26, "CHF"); Money result= m12CHF.add(m14CHF); assertTrue(expected.equals(result)); }</tt></pre> </blockquote> If you want to write a test similar to one you have already written, write a Fixture instead. <h2> Fixture</h2> What if you have two or more tests that operate on the same or similar sets of objects? <p>Tests need to run against the background of a known set of objects. This set of objects is called a test fixture. When you are writing tests you will often find that you spend more time writing the code to set up the fixture than you do in actually testing values. <p>To some extent, you can make writing the fixture code easier by paying careful attention to the constructors you write. However, a much bigger savings comes from sharing fixture code. Often, you will be able to use the same fixture for several different tests. Each case will send slightly different messages or parameters to the fixture and will check for different results. <p>When you have a common fixture, here is what you do: <ol> <li> Add a field for each part of the fixture</li> <li> Annotate a method with @org.junit.Before and initialize the variables in that method</li> <li> Annotate a method with @org.junit.After to release any permanent resources you allocated in setUp</li> </ol> For example, to write several test cases that want to work with different combinations of 12 Swiss Francs, 14 Swiss Francs, and 28 US Dollars, first create a fixture: <pre><tt>public class MoneyTest { private Money f12CHF; private Money f14CHF; private Money f28USD; @Before public void setUp() { f12CHF= new Money(12, "CHF"); f14CHF= new Money(14, "CHF"); f28USD= new Money(28, "USD"); } }</tt></pre> Once you have the Fixture in place, you can write as many Test Cases as you'd like. Add as many test methods (annotated with @Test) as you'd like. <h2> TestRunner</h2> How do you run your tests and collect their results? <p>Once you have tests, you'll want to run them. JUnit provides tools to define the suite to be run and to display its results. To run tests and see the results on the console, run: <blockquote> <pre><tt>org.junit.runner.TextListener.run(TestClass1.class, ...); </tt></pre> </blockquote> You make your JUnit 4 test classes accessible to a TestRunner designed to work with earlier versions of JUnit, declare a static method <i>suite</i> that returns a test. <blockquote> <pre><tt>public static junit.framework.Test suite() { return new JUnit4TestAdapter(Example.class); }</tt></pre> </blockquote> <h2> Expected Exceptions</h2> How do you verify that code throws exceptions as expected? <p>Verifying that code completes normally is only part of programming. Making sure the code behaves as expected in exceptional situations is part of the craft of programming too. For example: <blockquote> <pre><tt>new ArrayList<Object>().get(0); </tt></pre> </blockquote> This code should throw an IndexOutOfBoundsException. The @Test annotation has an optional parameter "expected" that takes as values subclasses of Throwable. If we wanted to verify that ArrayList throws the correct exception, we would write: <blockquote> <pre><tt>@Test(expected= IndexOutOfBoundsException.class) public void empty() { new ArrayList<Object>().get(0); }</tt></pre> </blockquote> <hr WIDTH="100%"> </body> </html> |
From: David S. <ds...@us...> - 2006-02-15 22:55:49
|
Update of /cvsroot/junit/junit/doc/testinfected In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/doc/testinfected Modified Files: testing.htm Log Message: Merged with branch, Kent will make final changes and launch. Index: testing.htm =================================================================== RCS file: /cvsroot/junit/junit/doc/testinfected/testing.htm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- testing.htm 5 Feb 2002 21:44:49 -0000 1.6 +++ testing.htm 15 Feb 2006 22:55:39 -0000 1.7 @@ -452,7 +452,7 @@ <pre><tt>public void testSimplify() { // {[12 CHF][7 USD]} + [-12 CHF] == [7 USD] Money expected= new Money(7, "USD"); - Assert.assertEquals(expected, fMS1.add(new Money(-12, "CHF"))); + Assert.assertEquals(expected, fMB1.add(new Money(-12, "CHF"))); }</tt></pre> When you are developing in this style you will often have a thought and turn immediately to writing a test, rather than going straight to the code. |
From: David S. <ds...@us...> - 2006-02-15 22:55:48
|
Update of /cvsroot/junit/junit/junit4.0/org/junit/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/junit4.0/org/junit/samples Added Files: SimpleTest.java ListTest.java Log Message: Merged with branch, Kent will make final changes and launch. --- NEW FILE: SimpleTest.java --- package org.junit.samples; import static org.junit.Assert.assertEquals; import junit.framework.JUnit4TestAdapter; import org.junit.Before; import org.junit.Test; /** * Some simple tests. * */ public class SimpleTest { protected int fValue1; protected int fValue2; @Before public void setUp() { fValue1= 2; fValue2= 3; } public static junit.framework.Test suite() { return new JUnit4TestAdapter(SimpleTest.class); } @Test public void divideByZero() { int zero= 0; int result= 8/zero; result++; // avoid warning for not using result } @Test public void testEquals() { assertEquals(12, 12); assertEquals(12L, 12L); assertEquals(new Long(12), new Long(12)); assertEquals("Size", 12, 13); assertEquals("Capacity", 12.0, 11.99, 0.0); } } --- NEW FILE: ListTest.java --- package org.junit.samples; import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; import junit.framework.JUnit4TestAdapter; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; /** * A sample test case, testing <code>java.util.Vector</code>. * */ public class ListTest { protected List<Integer> fEmpty; protected List<Integer> fFull; protected static List<Integer> fgHeavy; public static void main (String... args) { junit.textui.TestRunner.run (suite()); } @BeforeClass public static void setUpOnce() { fgHeavy= new ArrayList<Integer>(); for(int i= 0; i < 1000; i++) fgHeavy.add(i); } @Before public void setUp() { fEmpty= new ArrayList<Integer>(); fFull= new ArrayList<Integer>(); fFull.add(1); fFull.add(2); fFull.add(3); } public static junit.framework.Test suite() { return new JUnit4TestAdapter(ListTest.class); } @Ignore("not today") @Test public void capacity() { int size= fFull.size(); for (int i= 0; i < 100; i++) fFull.add(i); assertTrue(fFull.size() == 100+size); } @Test public void testCopy() { List<Integer> copy= new ArrayList<Integer>(fFull.size()); copy.addAll(fFull); assertTrue(copy.size() == fFull.size()); assertTrue(copy.contains(1)); } @Test public void contains() { assertTrue(fFull.contains(1)); assertTrue(!fEmpty.contains(1)); } @Test (expected=IndexOutOfBoundsException.class) public void elementAt() { int i= fFull.get(0); assertTrue(i == 1); fFull.get(fFull.size()); // Should throw IndexOutOfBoundsException } @Test public void removeAll() { fFull.removeAll(fFull); fEmpty.removeAll(fEmpty); assertTrue(fFull.isEmpty()); assertTrue(fEmpty.isEmpty()); } @Test public void removeElement() { fFull.remove(new Integer(3)); assertTrue(!fFull.contains(3)); } } |
From: David S. <ds...@us...> - 2006-02-15 22:55:48
|
Update of /cvsroot/junit/junit/junit/swingui/icons In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/junit/swingui/icons Removed Files: hierarchy.gif failure.gif error.gif ok.gif Log Message: Merged with branch, Kent will make final changes and launch. --- hierarchy.gif DELETED --- --- failure.gif DELETED --- --- error.gif DELETED --- --- ok.gif DELETED --- |
From: David S. <ds...@us...> - 2006-02-15 22:55:48
|
Update of /cvsroot/junit/junit/junit4.0/junit/tests/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/junit4.0/junit/tests/extensions Added Files: ExtensionTest$5.class ExtensionTest$3.class AllTests.java ExtensionTest.java ActiveTestTest.java ExtensionTest$2.class RepeatedTestTest.java ExtensionTest$4.class ExtensionTest$1.class Log Message: Merged with branch, Kent will make final changes and launch. --- NEW FILE: ExtensionTest$5.class --- Êþº¾ SourceFile *,· --- NEW FILE: ExtensionTest$3.class --- Êþº¾ SourceFile *,· --- NEW FILE: AllTests.java --- package junit.tests.extensions; import junit.framework.Test; import junit.framework.TestSuite; /** * TestSuite that runs all the extension tests * */ public class AllTests { public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } public static Test suite() { // Collect tests manually because we have to test class collection code TestSuite suite= new TestSuite("Framework Tests"); suite.addTestSuite(ExtensionTest.class); suite.addTestSuite(ActiveTestTest.class); suite.addTestSuite(RepeatedTestTest.class); return suite; } } --- NEW FILE: ExtensionTest.java --- package junit.tests.extensions; import junit.extensions.TestSetup; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestResult; import junit.framework.TestSuite; import junit.tests.WasRun; /** * A test case testing the extensions to the testing framework. * */ public class ExtensionTest extends TestCase { static class TornDown extends TestSetup { boolean fTornDown= false; TornDown(Test test) { super(test); } @Override protected void tearDown() { fTornDown= true; } } public void testRunningErrorInTestSetup() { TestCase test= new TestCase("failure") { @Override public void runTest() { fail(); } }; TestSetup wrapper= new TestSetup(test); TestResult result= new TestResult(); wrapper.run(result); assertTrue(!result.wasSuccessful()); } public void testRunningErrorsInTestSetup() { TestCase failure= new TestCase("failure") { @Override public void runTest() { fail(); } }; TestCase error= new TestCase("error") { @Override public void runTest() { throw new Error(); } }; TestSuite suite= new TestSuite(); suite.addTest(failure); suite.addTest(error); TestSetup wrapper= new TestSetup(suite); TestResult result= new TestResult(); wrapper.run(result); assertEquals(1, result.failureCount()); assertEquals(1, result.errorCount()); } public void testSetupErrorDontTearDown() { WasRun test= new WasRun(); TornDown wrapper= new TornDown(test) { @Override public void setUp() { fail(); } }; TestResult result= new TestResult(); wrapper.run(result); assertTrue(!wrapper.fTornDown); } public void testSetupErrorInTestSetup() { WasRun test= new WasRun(); TestSetup wrapper= new TestSetup(test) { @Override public void setUp() { fail(); } }; TestResult result= new TestResult(); wrapper.run(result); assertTrue(!test.fWasRun); assertTrue(!result.wasSuccessful()); } } --- NEW FILE: ActiveTestTest.java --- package junit.tests.extensions; import junit.extensions.ActiveTestSuite; import junit.extensions.RepeatedTest; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestResult; /** * Testing the ActiveTest support */ public class ActiveTestTest extends TestCase { public static class SuccessTest extends TestCase { @Override public void runTest() { } } public void testActiveTest() { Test test= createActiveTestSuite(); TestResult result= new TestResult(); test.run(result); assertEquals(100, result.runCount()); assertEquals(0, result.failureCount()); assertEquals(0, result.errorCount()); } public void testActiveRepeatedTest() { Test test= new RepeatedTest(createActiveTestSuite(), 5); TestResult result= new TestResult(); test.run(result); assertEquals(500, result.runCount()); assertEquals(0, result.failureCount()); assertEquals(0, result.errorCount()); } public void testActiveRepeatedTest0() { Test test= new RepeatedTest(createActiveTestSuite(), 0); TestResult result= new TestResult(); test.run(result); assertEquals(0, result.runCount()); assertEquals(0, result.failureCount()); assertEquals(0, result.errorCount()); } public void testActiveRepeatedTest1() { Test test= new RepeatedTest(createActiveTestSuite(), 1); TestResult result= new TestResult(); test.run(result); assertEquals(100, result.runCount()); assertEquals(0, result.failureCount()); assertEquals(0, result.errorCount()); } ActiveTestSuite createActiveTestSuite() { ActiveTestSuite suite= new ActiveTestSuite(); for (int i= 0; i < 100; i++) suite.addTest(new SuccessTest()); return suite; } } --- NEW FILE: ExtensionTest$2.class --- Êþº¾ SourceFile *,· --- NEW FILE: RepeatedTestTest.java --- package junit.tests.extensions; import junit.extensions.RepeatedTest; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestResult; import junit.framework.TestSuite; /** * Testing the RepeatedTest support. */ public class RepeatedTestTest extends TestCase { private TestSuite fSuite; public static class SuccessTest extends TestCase { @Override public void runTest() { } } public RepeatedTestTest(String name) { super(name); fSuite= new TestSuite(); fSuite.addTest(new SuccessTest()); fSuite.addTest(new SuccessTest()); } public void testRepeatedOnce() { Test test= new RepeatedTest(fSuite, 1); assertEquals(2, test.countTestCases()); TestResult result= new TestResult(); test.run(result); assertEquals(2, result.runCount()); } public void testRepeatedMoreThanOnce() { Test test= new RepeatedTest(fSuite, 3); assertEquals(6, test.countTestCases()); TestResult result= new TestResult(); test.run(result); assertEquals(6, result.runCount()); } public void testRepeatedZero() { Test test= new RepeatedTest(fSuite, 0); assertEquals(0, test.countTestCases()); TestResult result= new TestResult(); test.run(result); assertEquals(0, result.runCount()); } public void testRepeatedNegative() { try { new RepeatedTest(fSuite, -1); } catch (IllegalArgumentException e) { return; } fail("Should throw an IllegalArgumentException"); } } --- NEW FILE: ExtensionTest$4.class --- Êþº¾ SourceFile *,· --- NEW FILE: ExtensionTest$1.class --- Êþº¾ SourceFile *,· |
From: David S. <ds...@us...> - 2006-02-15 22:55:48
|
Update of /cvsroot/junit/junit/junit/swingui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/junit/swingui Removed Files: TestSuitePanel.java TestSelector.java FailureRunView.java TestTreeModel.java MacProgressBar.java TestRunContext.java TestRunner.java TestRunView.java StatusLine.java CounterPanel.java ProgressBar.java DefaultFailureDetailView.java TestHierarchyRunView.java AboutDialog.java Log Message: Merged with branch, Kent will make final changes and launch. --- TestSuitePanel.java DELETED --- --- TestSelector.java DELETED --- --- FailureRunView.java DELETED --- --- TestTreeModel.java DELETED --- --- MacProgressBar.java DELETED --- --- TestRunContext.java DELETED --- --- TestRunner.java DELETED --- --- TestRunView.java DELETED --- --- StatusLine.java DELETED --- --- CounterPanel.java DELETED --- --- ProgressBar.java DELETED --- --- DefaultFailureDetailView.java DELETED --- --- TestHierarchyRunView.java DELETED --- --- AboutDialog.java DELETED --- |
From: David S. <ds...@us...> - 2006-02-15 22:55:48
|
Update of /cvsroot/junit/junit/junit4.0/junit/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/junit4.0/junit/tests Added Files: WasRun.java AllTests.java Log Message: Merged with branch, Kent will make final changes and launch. --- NEW FILE: WasRun.java --- package junit.tests; import junit.framework.TestCase; /** * A helper test case for testing whether the testing method * is run. */ public class WasRun extends TestCase { public boolean fWasRun= false; @Override protected void runTest() { fWasRun= true; } } --- NEW FILE: AllTests.java --- package junit.tests; import junit.framework.Test; import junit.framework.TestSuite; /** * TestSuite that runs all the JUnit tests * */ public class AllTests { public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } public static Test suite() { TestSuite suite= new TestSuite("Framework Tests"); suite.addTest(junit.tests.framework.AllTests.suite()); suite.addTest(junit.tests.runner.AllTests.suite()); suite.addTest(junit.tests.extensions.AllTests.suite()); return suite; } } |
From: David S. <ds...@us...> - 2006-02-15 22:55:47
|
Update of /cvsroot/junit/junit/junit4.0/junit/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/junit4.0/junit/samples Added Files: SimpleTest.java AllTests.java ListTest.java Log Message: Merged with branch, Kent will make final changes and launch. --- NEW FILE: SimpleTest.java --- package junit.samples; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Some simple tests. * */ public class SimpleTest extends TestCase { protected int fValue1; protected int fValue2; @Override protected void setUp() { fValue1= 2; fValue2= 3; } public static Test suite() { /* * the type safe way * TestSuite suite= new TestSuite(); suite.addTest( new SimpleTest("add") { protected void runTest() { testAdd(); } } ); suite.addTest( new SimpleTest("testDivideByZero") { protected void runTest() { testDivideByZero(); } } ); return suite; */ /* * the dynamic way */ return new TestSuite(SimpleTest.class); } public void testAdd() { double result= fValue1 + fValue2; // forced failure result == 5 assertTrue(result == 6); } public void testDivideByZero() { int zero= 0; int result= 8/zero; result++; // avoid warning for not using result } public void testEquals() { assertEquals(12, 12); assertEquals(12L, 12L); assertEquals(new Long(12), new Long(12)); assertEquals("Size", 12, 13); assertEquals("Capacity", 12.0, 11.99, 0.0); } public static void main (String[] args) { junit.textui.TestRunner.run(suite()); } } --- NEW FILE: AllTests.java --- package junit.samples; import junit.framework.Test; import junit.framework.TestSuite; /** * TestSuite that runs all the sample tests * */ public class AllTests { public static void main (String[] args) { junit.textui.TestRunner.run (suite()); } public static Test suite ( ) { TestSuite suite= new TestSuite("All JUnit Tests"); suite.addTest(ListTest.suite()); suite.addTest(new TestSuite(junit.samples.money.MoneyTest.class)); suite.addTest(junit.tests.AllTests.suite()); return suite; } } --- NEW FILE: ListTest.java --- package junit.samples; import java.util.ArrayList; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * A sample test case, testing <code>java.util.Vector</code>. * */ public class ListTest extends TestCase { protected List<Integer> fEmpty; protected List<Integer> fFull; public static void main (String[] args) { junit.textui.TestRunner.run (suite()); } @Override protected void setUp() { fEmpty= new ArrayList<Integer>(); fFull= new ArrayList<Integer>(); fFull.add(1); fFull.add(2); fFull.add(3); } public static Test suite() { return new TestSuite(ListTest.class); } public void testCapacity() { int size= fFull.size(); for (int i= 0; i < 100; i++) fFull.add(new Integer(i)); assertTrue(fFull.size() == 100+size); } public void testContains() { assertTrue(fFull.contains(1)); assertTrue(!fEmpty.contains(1)); } public void testElementAt() { int i= fFull.get(0); assertTrue(i == 1); try { fFull.get(fFull.size()); } catch (IndexOutOfBoundsException e) { return; } fail("Should raise an ArrayIndexOutOfBoundsException"); } public void testRemoveAll() { fFull.removeAll(fFull); fEmpty.removeAll(fEmpty); assertTrue(fFull.isEmpty()); assertTrue(fEmpty.isEmpty()); } public void testRemoveElement() { fFull.remove(new Integer(3)); assertTrue(!fFull.contains(3) ); } } |
From: David S. <ds...@us...> - 2006-02-15 22:55:42
|
Update of /cvsroot/junit/junit/junit4.0/junit/samples/money In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/junit4.0/junit/samples/money Added Files: MoneyTest.java Money.java MoneyBag.java IMoney.java Log Message: Merged with branch, Kent will make final changes and launch. --- NEW FILE: MoneyTest.java --- package junit.samples.money; import junit.framework.TestCase; public class MoneyTest extends TestCase { private Money f12CHF; private Money f14CHF; private Money f7USD; private Money f21USD; private IMoney fMB1; private IMoney fMB2; public static void main(String args[]) { junit.textui.TestRunner.run(MoneyTest.class); } @Override protected void setUp() { f12CHF= new Money(12, "CHF"); f14CHF= new Money(14, "CHF"); f7USD= new Money( 7, "USD"); f21USD= new Money(21, "USD"); fMB1= MoneyBag.create(f12CHF, f7USD); fMB2= MoneyBag.create(f14CHF, f21USD); } public void testBagMultiply() { // {[12 CHF][7 USD]} *2 == {[24 CHF][14 USD]} IMoney expected= MoneyBag.create(new Money(24, "CHF"), new Money(14, "USD")); assertEquals(expected, fMB1.multiply(2)); assertEquals(fMB1, fMB1.multiply(1)); assertTrue(fMB1.multiply(0).isZero()); } public void testBagNegate() { // {[12 CHF][7 USD]} negate == {[-12 CHF][-7 USD]} IMoney expected= MoneyBag.create(new Money(-12, "CHF"), new Money(-7, "USD")); assertEquals(expected, fMB1.negate()); } public void testBagSimpleAdd() { // {[12 CHF][7 USD]} + [14 CHF] == {[26 CHF][7 USD]} IMoney expected= MoneyBag.create(new Money(26, "CHF"), new Money(7, "USD")); assertEquals(expected, fMB1.add(f14CHF)); } public void testBagSubtract() { // {[12 CHF][7 USD]} - {[14 CHF][21 USD] == {[-2 CHF][-14 USD]} IMoney expected= MoneyBag.create(new Money(-2, "CHF"), new Money(-14, "USD")); assertEquals(expected, fMB1.subtract(fMB2)); } public void testBagSumAdd() { // {[12 CHF][7 USD]} + {[14 CHF][21 USD]} == {[26 CHF][28 USD]} IMoney expected= MoneyBag.create(new Money(26, "CHF"), new Money(28, "USD")); assertEquals(expected, fMB1.add(fMB2)); } public void testIsZero() { assertTrue(fMB1.subtract(fMB1).isZero()); assertTrue(MoneyBag.create(new Money (0, "CHF"), new Money (0, "USD")).isZero()); } public void testMixedSimpleAdd() { // [12 CHF] + [7 USD] == {[12 CHF][7 USD]} IMoney expected= MoneyBag.create(f12CHF, f7USD); assertEquals(expected, f12CHF.add(f7USD)); } public void testBagNotEquals() { IMoney bag= MoneyBag.create(f12CHF, f7USD); assertFalse(bag.equals(new Money(12, "DEM").add(f7USD))); } public void testMoneyBagEquals() { assertTrue(!fMB1.equals(null)); assertEquals(fMB1, fMB1); IMoney equal= MoneyBag.create(new Money(12, "CHF"), new Money(7, "USD")); assertTrue(fMB1.equals(equal)); assertTrue(!fMB1.equals(f12CHF)); assertTrue(!f12CHF.equals(fMB1)); assertTrue(!fMB1.equals(fMB2)); } public void testMoneyBagHash() { IMoney equal= MoneyBag.create(new Money(12, "CHF"), new Money(7, "USD")); assertEquals(fMB1.hashCode(), equal.hashCode()); } public void testMoneyEquals() { assertTrue(!f12CHF.equals(null)); Money equalMoney= new Money(12, "CHF"); assertEquals(f12CHF, f12CHF); assertEquals(f12CHF, equalMoney); assertEquals(f12CHF.hashCode(), equalMoney.hashCode()); assertTrue(!f12CHF.equals(f14CHF)); } public void testMoneyHash() { assertTrue(!f12CHF.equals(null)); Money equal= new Money(12, "CHF"); assertEquals(f12CHF.hashCode(), equal.hashCode()); } public void testSimplify() { IMoney money= MoneyBag.create(new Money(26, "CHF"), new Money(28, "CHF")); assertEquals(new Money(54, "CHF"), money); } public void testNormalize2() { // {[12 CHF][7 USD]} - [12 CHF] == [7 USD] Money expected= new Money(7, "USD"); assertEquals(expected, fMB1.subtract(f12CHF)); } public void testNormalize3() { // {[12 CHF][7 USD]} - {[12 CHF][3 USD]} == [4 USD] IMoney ms1= MoneyBag.create(new Money(12, "CHF"), new Money(3, "USD")); Money expected= new Money(4, "USD"); assertEquals(expected, fMB1.subtract(ms1)); } public void testNormalize4() { // [12 CHF] - {[12 CHF][3 USD]} == [-3 USD] IMoney ms1= MoneyBag.create(new Money(12, "CHF"), new Money(3, "USD")); Money expected= new Money(-3, "USD"); assertEquals(expected, f12CHF.subtract(ms1)); } public void testPrint() { assertEquals("[12 CHF]", f12CHF.toString()); } public void testSimpleAdd() { // [12 CHF] + [14 CHF] == [26 CHF] Money expected= new Money(26, "CHF"); assertEquals(expected, f12CHF.add(f14CHF)); } public void testSimpleBagAdd() { // [14 CHF] + {[12 CHF][7 USD]} == {[26 CHF][7 USD]} IMoney expected= MoneyBag.create(new Money(26, "CHF"), new Money(7, "USD")); assertEquals(expected, f14CHF.add(fMB1)); } public void testSimpleMultiply() { // [14 CHF] *2 == [28 CHF] Money expected= new Money(28, "CHF"); assertEquals(expected, f14CHF.multiply(2)); } public void testSimpleNegate() { // [14 CHF] negate == [-14 CHF] Money expected= new Money(-14, "CHF"); assertEquals(expected, f14CHF.negate()); } public void testSimpleSubtract() { // [14 CHF] - [12 CHF] == [2 CHF] Money expected= new Money(2, "CHF"); assertEquals(expected, f14CHF.subtract(f12CHF)); } } --- NEW FILE: Money.java --- package junit.samples.money; /** * A simple Money. * */ public class Money implements IMoney { private int fAmount; private String fCurrency; /** * Constructs a money from the given amount and currency. */ public Money(int amount, String currency) { fAmount= amount; fCurrency= currency; } /** * Adds a money to this money. Forwards the request to the addMoney helper. */ public IMoney add(IMoney m) { return m.addMoney(this); } public IMoney addMoney(Money m) { if (m.currency().equals(currency()) ) return new Money(amount()+m.amount(), currency()); return MoneyBag.create(this, m); } public IMoney addMoneyBag(MoneyBag s) { return s.addMoney(this); } public int amount() { return fAmount; } public String currency() { return fCurrency; } @Override public boolean equals(Object anObject) { if (isZero()) if (anObject instanceof IMoney) return ((IMoney)anObject).isZero(); if (anObject instanceof Money) { Money aMoney= (Money)anObject; return aMoney.currency().equals(currency()) && amount() == aMoney.amount(); } return false; } @Override public int hashCode() { if (fAmount == 0) return 0; return fCurrency.hashCode()+fAmount; } public boolean isZero() { return amount() == 0; } public IMoney multiply(int factor) { return new Money(amount()*factor, currency()); } public IMoney negate() { return new Money(-amount(), currency()); } public IMoney subtract(IMoney m) { return add(m.negate()); } @Override public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("["+amount()+" "+currency()+"]"); return buffer.toString(); } public /*this makes no sense*/ void appendTo(MoneyBag m) { m.appendMoney(this); } } --- NEW FILE: MoneyBag.java --- package junit.samples.money; import java.util.ArrayList; import java.util.List; /** * A MoneyBag defers exchange rate conversions. For example adding * 12 Swiss Francs to 14 US Dollars is represented as a bag * containing the two Monies 12 CHF and 14 USD. Adding another * 10 Swiss francs gives a bag with 22 CHF and 14 USD. Due to * the deferred exchange rate conversion we can later value a * MoneyBag with different exchange rates. * * A MoneyBag is represented as a list of Monies and provides * different constructors to create a MoneyBag. */ public class MoneyBag implements IMoney { private List<Money> fMonies= new ArrayList<Money>(5); public static IMoney create(IMoney m1, IMoney m2) { MoneyBag result= new MoneyBag(); m1.appendTo(result); m2.appendTo(result); return result.simplify(); } public IMoney add(IMoney m) { return m.addMoneyBag(this); } public IMoney addMoney(Money m) { return MoneyBag.create(m, this); } public IMoney addMoneyBag(MoneyBag s) { return MoneyBag.create(s, this); } void appendBag(MoneyBag aBag) { for (Money each : aBag.fMonies) appendMoney(each); } void appendMoney(Money aMoney) { if (aMoney.isZero()) return; IMoney old= findMoney(aMoney.currency()); if (old == null) { fMonies.add(aMoney); return; } fMonies.remove(old); Money sum= (Money) old.add(aMoney); if (sum.isZero()) return; fMonies.add(sum); } @Override public boolean equals(Object anObject) { if (isZero()) if (anObject instanceof IMoney) return ((IMoney)anObject).isZero(); if (anObject instanceof MoneyBag) { MoneyBag aMoneyBag= (MoneyBag)anObject; if (aMoneyBag.fMonies.size() != fMonies.size()) return false; for (Money each : fMonies) if (! aMoneyBag.contains(each)) return false; return true; } return false; } private Money findMoney(String currency) { for (Money each : fMonies) if (each.currency().equals(currency)) return each; return null; } private boolean contains(Money m) { Money found= findMoney(m.currency()); if (found == null) return false; return found.amount() == m.amount(); } @Override public int hashCode() { int hash= 0; for (Money each : fMonies) hash^= each.hashCode(); return hash; } public boolean isZero() { return fMonies.size() == 0; } public IMoney multiply(int factor) { MoneyBag result= new MoneyBag(); if (factor != 0) for (Money each : fMonies) result.appendMoney((Money) each.multiply(factor)); return result; } public IMoney negate() { MoneyBag result= new MoneyBag(); for (Money each : fMonies) result.appendMoney((Money) each.negate()); return result; } private IMoney simplify() { if (fMonies.size() == 1) return fMonies.iterator().next(); return this; } public IMoney subtract(IMoney m) { return add(m.negate()); } @Override public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("{"); for (Money each : fMonies) buffer.append(each); buffer.append("}"); return buffer.toString(); } public void appendTo(MoneyBag m) { m.appendBag(this); } } --- NEW FILE: IMoney.java --- package junit.samples.money; /** * The common interface for simple Monies and MoneyBags * */ public interface IMoney { /** * Adds a money to this money. */ public abstract IMoney add(IMoney m); /** * Adds a simple Money to this money. This is a helper method for * implementing double dispatch */ public abstract IMoney addMoney(Money m); /** * Adds a MoneyBag to this money. This is a helper method for * implementing double dispatch */ public abstract IMoney addMoneyBag(MoneyBag s); /** * Tests whether this money is zero */ public abstract boolean isZero(); /** * Multiplies a money by the given factor. */ public abstract IMoney multiply(int factor); /** * Negates this money. */ public abstract IMoney negate(); /** * Subtracts a money from this money. */ public abstract IMoney subtract(IMoney m); /** * Append this to a MoneyBag m. * appendTo() needs to be public because it is used * polymorphically, but it should not be used by clients * because it modifies the argument m. */ public abstract void appendTo(MoneyBag m); } |
Update of /cvsroot/junit/junit/junit4.0/junit/tests/framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/junit4.0/junit/tests/framework Added Files: TestCaseTest$7.class Failure.java SuiteTest.java DoublePrecisionAssertTest.java ComparisonCompactorTest.java NotPublicTestCase.java TestCaseTest$6.class NoTestCaseClass.java TestImplementorTest.java NoTestCases.java NotVoidTestCase.java NoArgTestCaseTest.java AllTests.java TestListenerTest$1.class TestCaseTest$2.class TestImplementorTest$DoubleTestCase$1.class Success.java TestCaseTest$4.class TestCaseTest.java OverrideTestCase.java ComparisonFailureTest.java TestCaseTest$1.class TestCaseTest$9.class TestCaseTest$5.class TestListenerTest.java TestListenerTest$3.class FloatAssertTest.java TestListenerTest$2.class TestCaseTest$8.class InheritedTestCase.java TestImplementorTest$1.class OneTestCase.java AssertTest.java TestCaseTest$10.class TestCaseTest$3.class Log Message: Merged with branch, Kent will make final changes and launch. --- NEW FILE: TestCaseTest$7.class --- Êþº¾ SourceFile *+µ *· --- NEW FILE: Failure.java --- package junit.tests.framework; import junit.framework.TestCase; /** * A test case testing the testing framework. * */ public class Failure extends TestCase { @Override public void runTest() { fail(); } } --- NEW FILE: SuiteTest.java --- package junit.tests.framework; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestResult; import junit.framework.TestSuite; /** * A fixture for testing the "auto" test suite feature. * */ public class SuiteTest extends TestCase { protected TestResult fResult; public SuiteTest(String name) { super(name); } @Override protected void setUp() { fResult= new TestResult(); } public static Test suite() { TestSuite suite= new TestSuite("Suite Tests"); // build the suite manually, because some of the suites are testing // the functionality that automatically builds suites suite.addTest(new SuiteTest("testNoTestCases")); suite.addTest(new SuiteTest("testOneTestCase")); suite.addTest(new SuiteTest("testNotPublicTestCase")); suite.addTest(new SuiteTest("testNotVoidTestCase")); suite.addTest(new SuiteTest("testNotExistingTestCase")); suite.addTest(new SuiteTest("testInheritedTests")); suite.addTest(new SuiteTest("testShadowedTests")); suite.addTest(new SuiteTest("testAddTestSuite")); suite.addTest(new SuiteTest("testCreateSuiteFromArray")); return suite; } public void testInheritedTests() { TestSuite suite= new TestSuite(InheritedTestCase.class); suite.run(fResult); assertTrue(fResult.wasSuccessful()); assertEquals(2, fResult.runCount()); } // This test case is obsolete, since the compiler will catch this error in 1.5 // public void testNoTestCaseClass() { // Test t= new TestSuite(NoTestCaseClass.class); // t.run(fResult); // assertEquals(1, fResult.runCount()); // warning test // assertTrue(! fResult.wasSuccessful()); // } public void testNoTestCases() { Test t= new TestSuite(NoTestCases.class); t.run(fResult); assertTrue(fResult.runCount() == 1); // warning test assertTrue(fResult.failureCount() == 1); assertTrue(! fResult.wasSuccessful()); } public void testNotExistingTestCase() { Test t= new SuiteTest("notExistingMethod"); t.run(fResult); assertTrue(fResult.runCount() == 1); assertTrue(fResult.failureCount() == 1); assertTrue(fResult.errorCount() == 0); } public void testNotPublicTestCase() { TestSuite suite= new TestSuite(NotPublicTestCase.class); // 1 public test case + 1 warning for the non-public test case assertEquals(2, suite.countTestCases()); } public void testNotVoidTestCase() { TestSuite suite= new TestSuite(NotVoidTestCase.class); assertTrue(suite.countTestCases() == 1); } public void testOneTestCase() { Test t= new TestSuite(OneTestCase.class); t.run(fResult); assertTrue(fResult.runCount() == 1); assertTrue(fResult.failureCount() == 0); assertTrue(fResult.errorCount() == 0); assertTrue(fResult.wasSuccessful()); } public void testShadowedTests() { TestSuite suite= new TestSuite(OverrideTestCase.class); suite.run(fResult); assertEquals(1, fResult.runCount()); } public void testAddTestSuite() { TestSuite suite= new TestSuite(); suite.addTestSuite(OneTestCase.class); suite.run(fResult); assertEquals(1, fResult.runCount()); } public void testCreateSuiteFromArray() { TestSuite suite = new TestSuite(OneTestCase.class, DoublePrecisionAssertTest.class); assertEquals(2, suite.testCount()); assertEquals("junit.tests.framework.DoublePrecisionAssertTest" , ((TestSuite)suite.testAt(1)).getName()); assertEquals("junit.tests.framework.OneTestCase" , ((TestSuite)suite.testAt(0)).getName()); } } --- NEW FILE: DoublePrecisionAssertTest.java --- package junit.tests.framework; import junit.framework.AssertionFailedError; import junit.framework.TestCase; public class DoublePrecisionAssertTest extends TestCase { /** * Test for the special Double.NaN value. */ public void testAssertEqualsNaNFails() { try { assertEquals(1.234, Double.NaN, 0.0); fail(); } catch (AssertionFailedError e) { } } public void testAssertNaNEqualsFails() { try { assertEquals(Double.NaN, 1.234, 0.0); fail(); } catch (AssertionFailedError e) { } } public void testAssertNaNEqualsNaN() { assertEquals(Double.NaN, Double.NaN, 0.0); } public void testAssertPosInfinityNotEqualsNegInfinity() { try { assertEquals(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0.0); fail(); } catch (AssertionFailedError e) { } } public void testAssertPosInfinityNotEquals() { try { assertEquals(Double.POSITIVE_INFINITY, 1.23, 0.0); fail(); } catch (AssertionFailedError e) { } } public void testAssertPosInfinityEqualsInfinity() { assertEquals(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 0.0); } public void testAssertNegInfinityEqualsInfinity() { assertEquals(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 0.0); } } --- NEW FILE: ComparisonCompactorTest.java --- package junit.tests.framework; import junit.framework.ComparisonCompactor; import junit.framework.TestCase; public class ComparisonCompactorTest extends TestCase { public void testMessage() { String failure= new ComparisonCompactor(0, "b", "c").compact("a"); assertTrue("a expected:<[b]> but was:<[c]>".equals(failure)); } public void testStartSame() { String failure= new ComparisonCompactor(1, "ba", "bc").compact(null); assertEquals("expected:<b[a]> but was:<b[c]>", failure); } public void testEndSame() { String failure= new ComparisonCompactor(1, "ab", "cb").compact(null); assertEquals("expected:<[a]b> but was:<[c]b>", failure); } public void testSame() { String failure= new ComparisonCompactor(1, "ab", "ab").compact(null); assertEquals("expected:<ab> but was:<ab>", failure); } public void testNoContextStartAndEndSame() { String failure= new ComparisonCompactor(0, "abc", "adc").compact(null); assertEquals("expected:<...[b]...> but was:<...[d]...>", failure); } public void testStartAndEndContext() { String failure= new ComparisonCompactor(1, "abc", "adc").compact(null); assertEquals("expected:<a[b]c> but was:<a[d]c>", failure); } public void testStartAndEndContextWithEllipses() { String failure= new ComparisonCompactor(1, "abcde", "abfde").compact(null); assertEquals("expected:<...b[c]d...> but was:<...b[f]d...>", failure); } public void testComparisonErrorStartSameComplete() { String failure= new ComparisonCompactor(2, "ab", "abc").compact(null); assertEquals("expected:<ab[]> but was:<ab[c]>", failure); } public void testComparisonErrorEndSameComplete() { String failure= new ComparisonCompactor(0, "bc", "abc").compact(null); assertEquals("expected:<[]...> but was:<[a]...>", failure); } public void testComparisonErrorEndSameCompleteContext() { String failure= new ComparisonCompactor(2, "bc", "abc").compact(null); assertEquals("expected:<[]bc> but was:<[a]bc>", failure); } public void testComparisonErrorOverlapingMatches() { String failure= new ComparisonCompactor(0, "abc", "abbc").compact(null); assertEquals("expected:<...[]...> but was:<...[b]...>", failure); } public void testComparisonErrorOverlapingMatchesContext() { String failure= new ComparisonCompactor(2, "abc", "abbc").compact(null); assertEquals("expected:<ab[]c> but was:<ab[b]c>", failure); } public void testComparisonErrorOverlapingMatches2() { String failure= new ComparisonCompactor(0, "abcdde", "abcde").compact(null); assertEquals("expected:<...[d]...> but was:<...[]...>", failure); } public void testComparisonErrorOverlapingMatches2Context() { String failure= new ComparisonCompactor(2, "abcdde", "abcde").compact(null); assertEquals("expected:<...cd[d]e> but was:<...cd[]e>", failure); } public void testComparisonErrorWithActualNull() { String failure= new ComparisonCompactor(0, "a", null).compact(null); assertEquals("expected:<a> but was:<null>", failure); } public void testComparisonErrorWithActualNullContext() { String failure= new ComparisonCompactor(2, "a", null).compact(null); assertEquals("expected:<a> but was:<null>", failure); } public void testComparisonErrorWithExpectedNull() { String failure= new ComparisonCompactor(0, null, "a").compact(null); assertEquals("expected:<null> but was:<a>", failure); } public void testComparisonErrorWithExpectedNullContext() { String failure= new ComparisonCompactor(2, null, "a").compact(null); assertEquals("expected:<null> but was:<a>", failure); } public void testBug609972() { String failure= new ComparisonCompactor(10, "S&P500", "0").compact(null); assertEquals("expected:<[S&P50]0> but was:<[]0>", failure); } } --- NEW FILE: NotPublicTestCase.java --- package junit.tests.framework; /** * Test class used in SuiteTest */ import junit.framework.TestCase; public class NotPublicTestCase extends TestCase { protected void testNotPublic() { } public void testPublic() { } } --- NEW FILE: TestCaseTest$6.class --- Êþº¾ SourceFile *,· --- NEW FILE: NoTestCaseClass.java --- package junit.tests.framework; /** * Test class used in SuiteTest */ public class NoTestCaseClass extends Object { public void testSuccess() { } } --- NEW FILE: TestImplementorTest.java --- package junit.tests.framework; import junit.framework.Protectable; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestResult; /** * Test an implementor of junit.framework.Test other than TestCase or TestSuite */ public class TestImplementorTest extends TestCase { public static class DoubleTestCase implements Test { private TestCase fTestCase; public DoubleTestCase(TestCase testCase) { fTestCase= testCase; } public int countTestCases() { return 2; } public void run(TestResult result) { result.startTest(this); Protectable p= new Protectable() { public void protect() throws Throwable { fTestCase.runBare(); fTestCase.runBare(); } }; result.runProtected(this, p); result.endTest(this); } } private DoubleTestCase fTest; public TestImplementorTest() { TestCase testCase= new TestCase() { @Override public void runTest() { } }; fTest= new DoubleTestCase(testCase); } public void testSuccessfulRun() { TestResult result= new TestResult(); fTest.run(result); assertEquals(fTest.countTestCases(), result.runCount()); assertEquals(0, result.errorCount()); assertEquals(0, result.failureCount()); } } --- NEW FILE: NoTestCases.java --- package junit.tests.framework; /** * Test class used in SuiteTest */ import junit.framework.TestCase; public class NoTestCases extends TestCase { public void noTestCase() { } } --- NEW FILE: NotVoidTestCase.java --- package junit.tests.framework; /** * Test class used in SuiteTest */ import junit.framework.TestCase; public class NotVoidTestCase extends TestCase { public int testNotVoid() { return 1; } public void testVoid() { } } --- NEW FILE: NoArgTestCaseTest.java --- package junit.tests.framework; import junit.framework.TestCase; public class NoArgTestCaseTest extends TestCase { public void testNothing() { // If this compiles, the no arg ctor is there } } --- NEW FILE: AllTests.java --- package junit.tests.framework; import junit.framework.Test; import junit.framework.TestSuite; /** * TestSuite that runs all the sample tests * */ public class AllTests { public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } public static Test suite() { TestSuite suite= new TestSuite("Framework Tests"); suite.addTestSuite(TestCaseTest.class); suite.addTest(SuiteTest.suite()); // Tests suite building, so can't use automatic test extraction suite.addTestSuite(TestListenerTest.class); suite.addTestSuite(AssertTest.class); suite.addTestSuite(TestImplementorTest.class); suite.addTestSuite(NoArgTestCaseTest.class); suite.addTestSuite(ComparisonCompactorTest.class); suite.addTestSuite(ComparisonFailureTest.class); suite.addTestSuite(DoublePrecisionAssertTest.class); suite.addTestSuite(FloatAssertTest.class); return suite; } } --- NEW FILE: TestListenerTest$1.class --- Êþº¾ SourceFile *,· --- NEW FILE: TestCaseTest$2.class --- Êþº¾ SourceFile *+µ *· --- NEW FILE: TestImplementorTest$DoubleTestCase$1.class --- Êþº¾ Exceptions SourceFile *+µ --- NEW FILE: Success.java --- package junit.tests.framework; import junit.framework.TestCase; /** * A test case testing the testing framework. * */ public class Success extends TestCase { @Override public void runTest() { } public void testSuccess() { } } --- NEW FILE: TestCaseTest$4.class --- Êþº¾ SourceFile *,· --- NEW FILE: TestCaseTest.java --- package junit.tests.framework; import junit.framework.AssertionFailedError; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestFailure; import junit.framework.TestResult; import junit.framework.TestSuite; import junit.tests.WasRun; /** * A test case testing the testing framework. * */ public class TestCaseTest extends TestCase { static class TornDown extends TestCase { boolean fTornDown= false; @Override protected void tearDown() { fTornDown= true; } @Override protected void runTest() { throw new Error("running"); } } public void testCaseToString() { // This test wins the award for twisted snake tail eating while // writing self tests. And you thought those weird anonymous // inner classes were bad... assertEquals("testCaseToString(junit.tests.framework.TestCaseTest)", toString()); } public void testError() { TestCase error= new TestCase("error") { @Override protected void runTest() { throw new Error(); } }; verifyError(error); } public void testRunAndTearDownFails() { TornDown fails= new TornDown() { @Override protected void tearDown() { super.tearDown(); throw new Error(); } @Override protected void runTest() { throw new Error(); } }; verifyError(fails); assertTrue(fails.fTornDown); } public void testSetupFails() { TestCase fails= new TestCase("success") { @Override protected void setUp() { throw new Error(); } @Override protected void runTest() { } }; verifyError(fails); } public void testSuccess() { TestCase success= new TestCase("success") { @Override protected void runTest() { } }; verifySuccess(success); } public void testFailure() { TestCase failure= new TestCase("failure") { @Override protected void runTest() { fail(); } }; verifyFailure(failure); } public void testTearDownAfterError() { TornDown fails= new TornDown(); verifyError(fails); assertTrue(fails.fTornDown); } public void testTearDownFails() { TestCase fails= new TestCase("success") { @Override protected void tearDown() { throw new Error(); } @Override protected void runTest() { } }; verifyError(fails); } public void testTearDownSetupFails() { TornDown fails= new TornDown() { @Override protected void setUp() { throw new Error(); } }; verifyError(fails); assertTrue(!fails.fTornDown); } public void testWasRun() { WasRun test= new WasRun(); test.run(); assertTrue(test.fWasRun); } public void testExceptionRunningAndTearDown() { // With 1.4, we should // wrap the exception thrown while running with the exception thrown // while tearing down Test t= new TornDown() { @Override public void tearDown() { throw new Error("tearingDown"); } }; TestResult result= new TestResult(); t.run(result); TestFailure failure= result.errors().nextElement(); assertEquals("running", failure.thrownException().getMessage()); } public void testErrorTearingDownDoesntMaskErrorRunning() { final Exception running= new Exception("Running"); TestCase t= new TestCase() { @Override protected void runTest() throws Throwable { throw running; } @Override protected void tearDown() throws Exception { throw new Error("Tearing down"); } }; try { t.runBare(); } catch (Throwable thrown) { assertSame(running, thrown); } } public void testNoArgTestCasePasses() { Test t= new TestSuite(NoArgTestCaseTest.class); TestResult result= new TestResult(); t.run(result); assertTrue(result.runCount() == 1); assertTrue(result.failureCount() == 0); assertTrue(result.errorCount() == 0); } public void testNamelessTestCase() { TestCase t= new TestCase() {}; try { t.run(); fail(); } catch (AssertionFailedError e) { } } void verifyError(TestCase test) { TestResult result= test.run(); assertTrue(result.runCount() == 1); assertTrue(result.failureCount() == 0); assertTrue(result.errorCount() == 1); } void verifyFailure(TestCase test) { TestResult result= test.run(); assertTrue(result.runCount() == 1); assertTrue(result.failureCount() == 1); assertTrue(result.errorCount() == 0); } void verifySuccess(TestCase test) { TestResult result= test.run(); assertTrue(result.runCount() == 1); assertTrue(result.failureCount() == 0); assertTrue(result.errorCount() == 0); } } --- NEW FILE: OverrideTestCase.java --- package junit.tests.framework; /** * Test class used in SuiteTest */ public class OverrideTestCase extends OneTestCase { @Override public void testCase() { } } --- NEW FILE: ComparisonFailureTest.java --- package junit.tests.framework; import junit.framework.ComparisonFailure; import junit.framework.TestCase; public class ComparisonFailureTest extends TestCase { // Most of the tests are in ComparisonCompactorTest public void testConnection() { ComparisonFailure failure= new ComparisonFailure("warning", "Mary had a little lamb", "Mary had the little lamb"); assertEquals("warning expected:<Mary had [a] little lamb> but was:<Mary had [the] little lamb>", failure.getMessage()); } // This is like an instanceof test. public void testThrowing() { try { assertEquals("a", "b"); } catch (ComparisonFailure e) { return; } fail(); } } --- NEW FILE: TestCaseTest$1.class --- Êþº¾ SourceFile *,· --- NEW FILE: TestCaseTest$9.class --- Êþº¾ Exceptions SourceFile » --- NEW FILE: TestCaseTest$5.class --- Êþº¾ SourceFile *,· --- NEW FILE: TestListenerTest.java --- package junit.tests.framework; /** * Test class used in SuiteTest */ import junit.framework.AssertionFailedError; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestListener; import junit.framework.TestResult; public class TestListenerTest extends TestCase implements TestListener { private TestResult fResult; private int fStartCount; private int fEndCount; private int fFailureCount; private int fErrorCount; public void addError(Test test, Throwable t) { fErrorCount++; } public void addFailure(Test test, AssertionFailedError t) { fFailureCount++; } public void endTest(Test test) { fEndCount++; } @Override protected void setUp() { fResult= new TestResult(); fResult.addListener(this); fStartCount= 0; fEndCount= 0; fFailureCount= 0; } public void startTest(Test test) { fStartCount++; } public void testError() { TestCase test= new TestCase("noop") { @Override public void runTest() { throw new Error(); } }; test.run(fResult); assertEquals(1, fErrorCount); assertEquals(1, fEndCount); } public void testFailure() { TestCase test= new TestCase("noop") { @Override public void runTest() { fail(); } }; test.run(fResult); assertEquals(1, fFailureCount); assertEquals(1, fEndCount); } public void testStartStop() { TestCase test= new TestCase("noop") { @Override public void runTest() { } }; test.run(fResult); assertEquals(1, fStartCount); assertEquals(1, fEndCount); } } --- NEW FILE: TestListenerTest$3.class --- Êþº¾ SourceFile *,· --- NEW FILE: FloatAssertTest.java --- package junit.tests.framework; import junit.framework.AssertionFailedError; import junit.framework.TestCase; public class FloatAssertTest extends TestCase { /** * Test for the special Double.NaN value. */ public void testAssertEqualsNaNFails() { try { assertEquals(1.234f, Float.NaN, 0.0); fail(); } catch (AssertionFailedError e) { } } public void testAssertNaNEqualsFails() { try { assertEquals(Float.NaN, 1.234f, 0.0); fail(); } catch (AssertionFailedError e) { } } public void testAssertNaNEqualsNaN() { assertEquals(Float.NaN, Float.NaN, 0.0); } public void testAssertPosInfinityNotEqualsNegInfinity() { try { assertEquals(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, 0.0); fail(); } catch (AssertionFailedError e) { } } public void testAssertPosInfinityNotEquals() { try { assertEquals(Float.POSITIVE_INFINITY, 1.23f, 0.0); fail(); } catch (AssertionFailedError e) { } } public void testAssertPosInfinityEqualsInfinity() { assertEquals(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, 0.0); } public void testAssertNegInfinityEqualsInfinity() { assertEquals(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY, 0.0); } public void testAllInfinities() { try { assertEquals(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY); fail(); } catch (AssertionFailedError e) { } } } --- NEW FILE: TestListenerTest$2.class --- Êþº¾ SourceFile *,· --- NEW FILE: TestCaseTest$8.class --- Êþº¾ SourceFile *+µ *· » --- NEW FILE: InheritedTestCase.java --- package junit.tests.framework; /** * Test class used in SuiteTest */ public class InheritedTestCase extends OneTestCase { public void test2() { } } --- NEW FILE: TestImplementorTest$1.class --- Êþº¾ SourceFile *+µ *· --- NEW FILE: OneTestCase.java --- package junit.tests.framework; /** * Test class used in SuiteTest */ import junit.framework.TestCase; public class OneTestCase extends TestCase { public void noTestCase() { } public void testCase() { } public void testCase(int arg) { } } --- NEW FILE: AssertTest.java --- package junit.tests.framework; import junit.framework.AssertionFailedError; import junit.framework.ComparisonFailure; import junit.framework.TestCase; public class AssertTest extends TestCase { /* In the tests that follow, we can't use standard formatting * for exception tests: * try { * somethingThatShouldThrow(); * fail(); * catch (AssertionFailedError e) { * } * because fail() would never be reported. */ public void testFail() { // Also, we are testing fail, so we can't rely on fail() working. // We have to throw the exception manually, . try { fail(); } catch (AssertionFailedError e) { return; } throw new AssertionFailedError(); } public void testAssertEquals() { Object o= new Object(); assertEquals(o, o); try { assertEquals(new Object(), new Object()); } catch (AssertionFailedError e) { return; } fail(); } public void testAssertEqualsNull() { assertEquals((Object) null, (Object) null); } public void testAssertStringEquals() { assertEquals("a", "a"); } public void testAssertNullNotEqualsString() { try { assertEquals(null, "foo"); fail(); } catch (ComparisonFailure e) { } } public void testAssertStringNotEqualsNull() { try { assertEquals("foo", null); fail(); } catch (ComparisonFailure e) { e.getMessage(); // why no assertion? } } public void testAssertNullNotEqualsNull() { try { assertEquals(null, new Object()); } catch (AssertionFailedError e) { e.getMessage(); // why no assertion? return; } fail(); } public void testAssertNull() { assertNull(null); try { assertNull(new Object()); } catch (AssertionFailedError e) { return; } fail(); } public void testAssertNotNull() { assertNotNull(new Object()); try { assertNotNull(null); } catch (AssertionFailedError e) { return; } fail(); } public void testAssertTrue() { assertTrue(true); try { assertTrue(false); } catch (AssertionFailedError e) { return; } fail(); } public void testAssertFalse() { assertFalse(false); try { assertFalse(true); } catch (AssertionFailedError e) { return; } fail(); } public void testAssertSame() { Object o= new Object(); assertSame(o, o); try { assertSame(new Integer(1), new Integer(1)); } catch (AssertionFailedError e) { return; } fail(); } public void testAssertNotSame() { assertNotSame(new Integer(1), null); assertNotSame(null, new Integer(1)); assertNotSame(new Integer(1), new Integer(1)); try { Integer obj= new Integer(1); assertNotSame(obj, obj); } catch (AssertionFailedError e) { return; } fail(); } public void testAssertNotSameFailsNull() { try { assertNotSame(null, null); } catch (AssertionFailedError e) { return; } fail(); } } --- NEW FILE: TestCaseTest$10.class --- Êþº¾ SourceFile *+µ *· --- NEW FILE: TestCaseTest$3.class --- Êþº¾ SourceFile *,· |
Update of /cvsroot/junit/junit/junit4.0/junit/tests/runner In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/junit4.0/junit/tests/runner Added Files: TextFeedbackTest$3.class TextFeedbackTest$5.class AllTests.java TextRunnerSingleMethodTest.java TextRunnerTest.java TextFeedbackTest$4.class TextFeedbackTest$7.class TextFeedbackTest$1.class TextFeedbackTest.java TextRunnerTest$1.class TextFeedbackTest$6.class BaseTestRunnerTest.java StackFilterTest.java TextFeedbackTest$2.class Log Message: Merged with branch, Kent will make final changes and launch. --- NEW FILE: TextFeedbackTest$3.class --- Êþº¾ SourceFile *+µ *· --- NEW FILE: TextFeedbackTest$5.class --- Êþº¾ SourceFile *+µ *· --- NEW FILE: AllTests.java --- package junit.tests.runner; import junit.framework.Test; import junit.framework.TestSuite; /** * TestSuite that runs all the sample tests * */ public class AllTests { public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } public static Test suite() { // Collect tests manually because we have to test class collection code TestSuite suite= new TestSuite("Framework Tests"); suite.addTestSuite(StackFilterTest.class); suite.addTestSuite(BaseTestRunnerTest.class); suite.addTestSuite(TextFeedbackTest.class); suite.addTestSuite(TextRunnerSingleMethodTest.class); suite.addTestSuite(TextRunnerTest.class); return suite; } static boolean isJDK11() { String version= System.getProperty("java.version"); return version.startsWith("1.1"); } } --- NEW FILE: TextRunnerSingleMethodTest.java --- package junit.tests.runner; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import junit.framework.TestCase; import junit.textui.ResultPrinter; import junit.textui.TestRunner; /** * Test invoking a single test method of a TestCase. */ public class TextRunnerSingleMethodTest extends TestCase { static boolean fgWasInvoked; public static class InvocationTest extends TestCase { public void testWasInvoked() { TextRunnerSingleMethodTest.fgWasInvoked= true; } public void testNotInvoked() { fail("Shouldn't get here."); } } public void testSingle() throws Exception { TestRunner t= new TestRunner(); t.setPrinter(new ResultPrinter(new PrintStream(new ByteArrayOutputStream()))); String[] args= { "-m", "junit.tests.runner.TextRunnerSingleMethodTest$InvocationTest.testWasInvoked" }; fgWasInvoked= false; t.start(args); assertTrue(fgWasInvoked); } } --- NEW FILE: TextRunnerTest.java --- package junit.tests.runner; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import junit.framework.TestCase; import junit.framework.TestResult; import junit.framework.TestSuite; public class TextRunnerTest extends TestCase { public void testFailure() throws Exception { execTest("junit.tests.framework.Failure", false); } public void testSuccess() throws Exception { execTest("junit.tests.framework.Success", true); } public void testError() throws Exception { execTest("junit.tests.BogusDude", false); } void execTest(String testClass, boolean success) throws Exception { String java= System.getProperty("java.home")+File.separator+"bin"+File.separator+"java"; String cp= System.getProperty("java.class.path"); //use -classpath for JDK 1.1.7 compatibility String [] cmd= { java, "-classpath", cp, "junit.textui.TestRunner", testClass}; Process p= Runtime.getRuntime().exec(cmd); InputStream i= p.getInputStream(); while((i.read()) != -1) ; //System.out.write(b); assertTrue((p.waitFor() == 0) == success); if (success) assertTrue(p.exitValue() == 0); else assertFalse(p.exitValue() == 0); } public void testRunReturnsResult() { PrintStream oldOut= System.out; System.setOut(new PrintStream ( new OutputStream() { @Override public void write(int arg0) throws IOException { } } )); try { TestResult result= junit.textui.TestRunner.run(new TestSuite()); assertTrue(result.wasSuccessful()); } finally { System.setOut(oldOut); } } } --- NEW FILE: TextFeedbackTest$4.class --- Êþº¾ SourceFile *,· *¶ --- NEW FILE: TextFeedbackTest$7.class --- Êþº¾ Exceptions SourceFile *+µ *· --- NEW FILE: TextFeedbackTest$1.class --- Êþº¾ SourceFile *+µ *· --- NEW FILE: TextFeedbackTest.java --- package junit.tests.runner; import java.io.ByteArrayOutputStream; import java.io.OutputStream; import java.io.PrintStream; import junit.framework.AssertionFailedError; import junit.framework.TestCase; import junit.framework.TestResult; import junit.framework.TestSuite; import junit.textui.ResultPrinter; import junit.textui.TestRunner; public class TextFeedbackTest extends TestCase { OutputStream output; TestRunner runner; static class TestResultPrinter extends ResultPrinter { TestResultPrinter(PrintStream writer) { super(writer); } /* Spoof printing time so the tests are deterministic */ @Override protected String elapsedTimeAsString(long runTime) { return "0"; } } public static void main(String[] args) { TestRunner.run(TextFeedbackTest.class); } @Override public void setUp() { output= new ByteArrayOutputStream(); runner= new TestRunner(new TestResultPrinter(new PrintStream(output))); } public void testEmptySuite() { String expected= expected(new String[]{"", "Time: 0", "", "OK (0 tests)", ""}); runner.doRun(new TestSuite()); assertEquals(expected, output.toString()); } public void testOneTest() { String expected= expected(new String[]{".", "Time: 0", "", "OK (1 test)", ""}); TestSuite suite = new TestSuite(); suite.addTest(new TestCase() { @Override public void runTest() {}}); runner.doRun(suite); assertEquals(expected, output.toString()); } public void testTwoTests() { String expected= expected(new String[]{"..", "Time: 0", "", "OK (2 tests)", ""}); TestSuite suite = new TestSuite(); suite.addTest(new TestCase() { @Override public void runTest() {}}); suite.addTest(new TestCase() { @Override public void runTest() {}}); runner.doRun(suite); assertEquals(expected, output.toString()); } public void testFailure() { String expected= expected(new String[]{".F", "Time: 0", "Failures here", "", "FAILURES!!!", "Tests run: 1, Failures: 1, Errors: 0", ""}); ResultPrinter printer= new TestResultPrinter(new PrintStream(output)) { @Override public void printFailures(TestResult result) { getWriter().println("Failures here"); } }; runner.setPrinter(printer); TestSuite suite = new TestSuite(); suite.addTest(new TestCase() { @Override public void runTest() {throw new AssertionFailedError();}}); runner.doRun(suite); assertEquals(expected, output.toString()); } public void testError() { String expected= expected(new String[]{".E", "Time: 0", "Errors here", "", "FAILURES!!!", "Tests run: 1, Failures: 0, Errors: 1", ""}); ResultPrinter printer= new TestResultPrinter(new PrintStream(output)) { @Override public void printErrors(TestResult result) { getWriter().println("Errors here"); } }; runner.setPrinter(printer); TestSuite suite = new TestSuite(); suite.addTest(new TestCase() { @Override public void runTest() throws Exception {throw new Exception();}}); runner.doRun(suite); assertEquals(expected, output.toString()); } private String expected(String[] lines) { OutputStream expected= new ByteArrayOutputStream(); PrintStream expectedWriter= new PrintStream(expected); for (int i= 0; i < lines.length; i++) expectedWriter.println(lines[i]); return expected.toString(); } } --- NEW FILE: TextRunnerTest$1.class --- Êþº¾ Exceptions SourceFile *+µ *· --- NEW FILE: TextFeedbackTest$6.class --- Êþº¾ SourceFile *,· *¶ --- NEW FILE: BaseTestRunnerTest.java --- package junit.tests.runner; import junit.framework.Test; import junit.framework.TestCase; import junit.runner.BaseTestRunner; public class BaseTestRunnerTest extends TestCase { public static class MockRunner extends BaseTestRunner { @Override protected void runFailed(String message) { } @Override public void testEnded(String testName) { } @Override public void testFailed(int status, Test test, Throwable t) { } @Override public void testStarted(String testName) { } } public static class NonStatic { public Test suite() { return null; } } public void testInvokeNonStaticSuite() { BaseTestRunner runner= new MockRunner(); runner.getTest("junit.tests.runner.BaseTestRunnerTest$NonStatic"); // Used to throw NullPointerException } } --- NEW FILE: StackFilterTest.java --- package junit.tests.runner; import java.io.PrintWriter; import java.io.StringWriter; import junit.framework.TestCase; import junit.runner.BaseTestRunner; public class StackFilterTest extends TestCase { String fFiltered; String fUnfiltered; @Override protected void setUp() { StringWriter swin= new StringWriter(); PrintWriter pwin= new PrintWriter(swin); pwin.println("junit.framework.AssertionFailedError"); pwin.println(" at junit.framework.Assert.fail(Assert.java:144)"); pwin.println(" at junit.framework.Assert.assert(Assert.java:19)"); pwin.println(" at junit.framework.Assert.assert(Assert.java:26)"); pwin.println(" at MyTest.f(MyTest.java:13)"); pwin.println(" at MyTest.testStackTrace(MyTest.java:8)"); pwin.println(" at java.lang.reflect.Method.invoke(Native Method)"); pwin.println(" at junit.framework.TestCase.runTest(TestCase.java:156)"); pwin.println(" at junit.framework.TestCase.runBare(TestCase.java:130)"); pwin.println(" at junit.framework.TestResult$1.protect(TestResult.java:100)"); pwin.println(" at junit.framework.TestResult.runProtected(TestResult.java:118)"); pwin.println(" at junit.framework.TestResult.run(TestResult.java:103)"); pwin.println(" at junit.framework.TestCase.run(TestCase.java:121)"); pwin.println(" at junit.framework.TestSuite.runTest(TestSuite.java:157)"); pwin.println(" at junit.framework.TestSuite.run(TestSuite.java, Compiled Code)"); pwin.println(" at junit.swingui.TestRunner$17.run(TestRunner.java:669)"); fUnfiltered= swin.toString(); StringWriter swout= new StringWriter(); PrintWriter pwout= new PrintWriter(swout); pwout.println("junit.framework.AssertionFailedError"); pwout.println(" at MyTest.f(MyTest.java:13)"); pwout.println(" at MyTest.testStackTrace(MyTest.java:8)"); fFiltered= swout.toString(); } public void testFilter() { assertEquals(fFiltered, BaseTestRunner.getFilteredTrace(fUnfiltered)); } } --- NEW FILE: TextFeedbackTest$2.class --- Êþº¾ SourceFile *+µ *· |
From: David S. <ds...@us...> - 2006-02-15 22:55:40
|
Update of /cvsroot/junit/junit/junit4.0/javadoc/resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/junit4.0/javadoc/resources Added Files: inherit.gif Log Message: Merged with branch, Kent will make final changes and launch. --- NEW FILE: inherit.gif --- GIF89a |
From: David S. <ds...@us...> - 2006-02-15 22:55:35
|
Update of /cvsroot/junit/junit/junit/awtui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13390/junit/awtui Removed Files: AboutDialog.java ProgressBar.java Logo.java TestRunner.java Log Message: Merged with branch, Kent will make final changes and launch. --- AboutDialog.java DELETED --- --- ProgressBar.java DELETED --- --- Logo.java DELETED --- --- TestRunner.java DELETED --- |
From: David S. <ds...@us...> - 2006-02-15 22:52:36
|
Update of /cvsroot/junit/junit/junit4.0/junit/samples/money In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12880/junit4.0/junit/samples/money Log Message: Directory /cvsroot/junit/junit/junit4.0/junit/samples/money added to the repository |
From: David S. <ds...@us...> - 2006-02-15 22:52:36
|
Update of /cvsroot/junit/junit/junit4.0/org In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12880/junit4.0/org Log Message: Directory /cvsroot/junit/junit/junit4.0/org added to the repository |
From: David S. <ds...@us...> - 2006-02-15 22:52:35
|
Update of /cvsroot/junit/junit/junit4.0/org/junit/samples/money In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12880/junit4.0/org/junit/samples/money Log Message: Directory /cvsroot/junit/junit/junit4.0/org/junit/samples/money added to the repository |
From: David S. <ds...@us...> - 2006-02-15 22:52:35
|
Update of /cvsroot/junit/junit/junit4.0/junit/tests/framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12880/junit4.0/junit/tests/framework Log Message: Directory /cvsroot/junit/junit/junit4.0/junit/tests/framework added to the repository |
From: David S. <ds...@us...> - 2006-02-15 22:52:35
|
Update of /cvsroot/junit/junit/junit4.0/org/junit/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12880/junit4.0/org/junit/tests Log Message: Directory /cvsroot/junit/junit/junit4.0/org/junit/tests added to the repository |
From: David S. <ds...@us...> - 2006-02-15 22:52:35
|
Update of /cvsroot/junit/junit/junit4.0/org/junit/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12880/junit4.0/org/junit/samples Log Message: Directory /cvsroot/junit/junit/junit4.0/org/junit/samples added to the repository |