From: David S. <ds...@us...> - 2007-07-02 18:11:02
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/theories/test/results In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv27902/src/org/junit/experimental/theories/test/results Added Files: PrintableResultTest.java ResultMatchersTest.java Log Message: - The hamcrest-core-1.1 library is now included in the JUnit distribution. For more hamcrest matchers, see the hamcrest-library jar from http://code.google.com/p/hamcrest - The Popper Theory runner (http://popper.tigris.org) has been absorbed into the JUnit project, under the package name org.junit.experimental.theories - Several additional libraries used in the theories tests have been added in a new testlib directory - New "assertThat" statement to work with hamcrest matchers: // same as assertEquals(3, x) assertThat(x, is(3)); // same as assertNull(y) assertThat(y, nullValue()); - New feature: assumeThat. A failed assumption will cause the test to pass, without further execution. (The behavior of assumeThat may change in the future to allow richer reporting of tests that are skipped because of failed assumptions) // pass on any non-Windows system @Test public void getRootDrive() { assumeThat(getOsString(), is("Windows")); getFile("C:\"); // ... } - Convenience assumption functions: // none of these are null assumeNotNull(a, b, c); assumeTrue(everythingOk()); try { getDatabaseConnection(); } catch (Exception e) { assumeNoException(e); } - Documentation fixed for many assertEquals array methods - Two bugs in numeric equality fixed: 1718905: assertEquals does not compare float correctly 1715326: assertEquals does not compare java.math.BigDecimal properly - The protocol for overriding JUnit4ClassRunner has changed again. Please see the source for details. - Extenders can now extend TestMethod to describe the behavior of running methods that do not have a @Test annotation. - Adding Annotations to Description caused a binary compatibility problem with clients compiled on previous JUnit versions. This has been fixed. --- NEW FILE: PrintableResultTest.java --- package org.junit.experimental.theories.test.results; import static java.util.Arrays.asList; import static org.hamcrest.Matchers.allOf; import static org.junit.Assert.assertThat; import java.util.Arrays; import org.hamcrest.Matchers; import org.junit.experimental.results.PrintableResult; import org.junit.experimental.theories.methods.api.Theory; import org.junit.experimental.theories.runner.api.Theories; import org.junit.runner.Description; import org.junit.runner.RunWith; import org.junit.runner.notification.Failure; @RunWith(Theories.class) public class PrintableResultTest { @SuppressWarnings("unchecked") @Theory(nullsAccepted= false) public void backTraceHasGoodToString(String descriptionName, final String stackTraceClassName) { Failure failure= new Failure(Description .createSuiteDescription(descriptionName), new Throwable() { private static final long serialVersionUID= 1L; @Override public StackTraceElement[] getStackTrace() { return new StackTraceElement[] { new StackTraceElement( stackTraceClassName, "methodName", "fileName", 1) }; } }); assertThat(new PrintableResult(asList(failure)).toString(), allOf( Matchers.containsString(descriptionName), Matchers .containsString(stackTraceClassName))); } public static String SHELL_POINT= "Shell Point"; @Theory public void includeMultipleFailures(String secondExceptionName) { PrintableResult backtrace= new PrintableResult(Arrays.asList( new Failure(Description.createSuiteDescription("firstName"), new RuntimeException("firstException")), new Failure( Description.createSuiteDescription("secondName"), new RuntimeException(secondExceptionName)))); assertThat(backtrace.toString(), Matchers .containsString(secondExceptionName)); } } --- NEW FILE: ResultMatchersTest.java --- package org.junit.experimental.theories.test.results; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.Matchers.hasToString; import static org.junit.Assert.assertThat; import org.hamcrest.Matchers; import org.junit.Test; import org.junit.experimental.results.ResultMatchers; import org.junit.experimental.theories.methods.api.Theory; public class ResultMatchersTest { @Test public void hasFailuresHasGoodDescription() { assertThat(ResultMatchers.failureCountIs(3).toString(), is("has 3 failures")); } @Theory public void hasFailuresDescriptionReflectsInput(int i) { assertThat(ResultMatchers.failureCountIs(i).toString(), hasToString(Matchers.containsString("" + i))); } } |