New 4.7 snapshot release: now with interceptors

David Saff <[email protected]> Mon, 4 May 2009 13:45:16 -0400
Newsgroups gmane.comp.java.junit.devel,gmane.comp.java.junit.user
Message-ID <[email protected]>
All,

We've bundled the most recent changes in the 4.7 branch into a
snapshot release here:

https://sourceforge.net/project/showfiles.php?group_id=15278&package_id=226053&release_id=679069

We think the new Interceptor support is a simple but powerful way to
get more control on how your methods are run and reported, and are
eager for feedback

  David Saff

## Summary of Changes in version 4.7 ##

### Interceptors ###

- Interceptors allow very flexible addition or redefinition of the behavior
  of each test method in a test class.  For example, this class will
  keep a log of each passing and failing test:

	@RunWith(Interceptors.class)
	public static class WatchmanTest {
		private static String watchedLog;

		@Interceptor
		public StatementInterceptor watchman= new TestWatchman() {
			@Override
			public void failed(Throwable e, FrameworkMethod method) {
				watchedLog+= method.getName() + " "
						+ e.getClass().getSimpleName() + "\n";
			}

			@Override
			public void succeeded(FrameworkMethod method) {
				watchedLog+= method.getName() + " " + "success!\n";
			}
		};

		@Test
		public void fails() {
			fail();
		}

		@Test
		public void succeeds() {
		}
	}

	For more on this feature, see http://www.threeriversinstitute.org/blog/?p=155

### Timeouts ###
- Tests that timeout now show the stack trace of the test thread.

### Docs ###
- Javadocs now link to online JDK javadocs (bug 2090230)
- Parameterized runner javadocs improved (bug 2186792)
- Fixed Javadoc code sample for AfterClass (2126279)

### Bug fixes ###
- Fixed: BaseTestRunner.getTest() requires class to extend TestCase (1812200)
- Fixed: Suite does not allow for inheritance in annotations (2783118)

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf