import org.junit.Rule; public class NameRuleTest { @Rule public TestName name = new TestName(); @Test public void testA() { assertEquals("testA", name.getMethodName()); } @Test public void testB() { assertEquals("testB", name.getMethodName()); } }
@Rule public ExpectedException expectedEx = ExpectedException.none(); @Test public void shouldThrowRuntimeExceptionWhenEmployeeIDisNull() throws Exception { expectedEx.expect(RuntimeException.class); expectedEx.expectMessage("Employee ID is null"); // do something that should throw the exception... }
private File getTestDirectory() { return temporaryFolder.getRoot(); }
@Test public void multiAnnotations() { thrown.expect(IllegalStateException.class); getCacheOperation(InvalidCases.class, name.getMethodName()); }
public class FooTest { @Rule public final ExpectedException exception = ExpectedException.none(); @Test public void doStuffThrowsIndexOutOfBoundsException() { Foo foo = new Foo(); exception.expect(IndexOutOfBoundsException.class); foo.doStuff(); } }
private void assertDefaultListenerMethodInvocation() { assertListenerMethodInvocation(this.sample, this.name.getMethodName()); }
private void expectExceptionWithZStd(CompressionType compressionType, byte magic) { if (compressionType == CompressionType.ZSTD && magic < MAGIC_VALUE_V2) { exceptionRule.expect(IllegalArgumentException.class); exceptionRule.expectMessage("ZStandard compression is not supported for magic " + magic); } } }
private File getTestDirectory() { return temporaryFolder.getRoot(); }
private void expectExceptionWithZStd(CompressionType compressionType, byte magic) { if (compressionType == CompressionType.ZSTD && magic < MAGIC_VALUE_V2) { exceptionRule.expect(IllegalArgumentException.class); exceptionRule.expectMessage("ZStandard compression is not supported for magic " + magic); } }
private File getTestDirectory() { return temporaryFolder.getRoot(); }
private void doTestSpr10146(String expression, String expectedMessage) { thrown.expect(SpelParseException.class); thrown.expectMessage(expectedMessage); new SpelExpressionParser().parseExpression(expression); }
private File getLocalTestDirectory() { return temporaryFolder.getRoot(); }
private File getTestDirectory() { return temporaryFolder.getRoot(); }
private File getTestDirectory() { return temporaryFolder.getRoot(); }
private File getTestDirectory() { return temporaryFolder.getRoot(); }
protected File getTestDirectory() { return temporaryFolder.getRoot(); }
private File getTestDirectory() { return temporaryFolder.getRoot(); }
private File getTestDirectory() { return temporaryFolder.getRoot(); }
private File getTestDirectory() { return temporaryFolder.getRoot(); }
private File getTestDirectory() { return temporaryFolder.getRoot(); }