Latest JUnit 4.7 snapshot, includes assertion on expected exception message text

David Saff <[email protected]> Wed, 27 May 2009 00:52:29 -0400
Newsgroups gmane.comp.java.junit.devel,gmane.comp.java.junit.user
Message-ID <[email protected]>
All,

In the latest snapshot build of JUnit 4.7, we=92ve re-implemented
expected exceptions using Interceptors.

Share and Enjoy, and let us know if the download experience is at all lacki=
ng.

http://github.com/KentBeck/junit/downloads

	public static class HasExpectedException {
		@Interceptor
		public ExpectedException thrown=3D new ExpectedException();

		@Test
		public void throwsNothing() {

		}

		@Test
		public void throwsNullPointerException() {
			thrown.expect(NullPointerException.class);
			throw new NullPointerException();
		}

		@Test
		public void throwsNullPointerExceptionWithMessage() {
			thrown.expect(NullPointerException.class);
			thrown.expectMessage("happened?");
			throw new NullPointerException("What happened?");
		}
	}

Thanks,

   David Saff

---------------------------------------------------------------------------=
---
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT =

is a gathering of tech-side developers & brand creativity professionals. Me=
et
the minds behind Google Creative Lab, Visual Complexity, Processing, & =

iPhoneDevCamp as they present alongside digital heavyweights like Barbarian =

Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com =