GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Assumptions with assume Assumptions with assume
Daan van Berkel edited this page
Ideally, the developer writing a test has control of all of the forces that might cause a test to fail. If this isn't immediately possible, making dependencies explicit can often improve a design. For example, if a test fails when run in a different locale than the developer intended, it can be fixed by explicitly passing a locale to the domain code. However, sometimes this is not desirable or possible. It's good to be able to run a test against the code as it is currently written, implicit assumptions and all, or to write a test that exposes a known bug. For these situations, JUnit now includes the ability to express "assumptions": import static org.junit.Assume.* @Test public void filenameIncludesUsername() { assumeThat(File.separatorChar, is('/')); assertThat(new User("optimus").configFileName(), is("configfiles/optimus.cfg")); } @Test public void correctBehaviorWhenFilenameIsNull() { assumeTrue(bugFixed("13356")); // bugFixed is not included in JUnit assertThat(parse(null), is(new NullDocument())); } The default JUnit runner treats tests with failing assumptions as ignored. Custom runners may behave differently. We have included A failing assumption in a Clone this wiki locally |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |