Code example for TestResult

Methods: wasSuccessful

0
	public static class NoExceptionTest { 
		@Test(expected=Exception.class) public void succeed() throws Exception { 
		} 
	} 
	public void testNoException() { 
		TestResult result= new TestResult();
		junit.framework.Test adapter= new JUnit4TestAdapter(NoExceptionTest.class);
		adapter.run(result);
		assertFalse(result.wasSuccessful());
	} 
	 
	public static class ExpectedTest { 
		@Test(expected= Exception.class) public void expected() throws Exception { 
			throw new Exception();
		} 
	} 
	public void testExpected() { 
		TestResult result= new TestResult();
		junit.framework.Test adapter= new JUnit4TestAdapter(ExpectedTest.class);
		adapter.run(result);
		assertTrue(result.wasSuccessful());