org.junit.rules
Class TestName
java.lang.Object
org.junit.rules.TestWatchman
org.junit.rules.TestName
- All Implemented Interfaces:
- MethodRule
public class TestName
- extends TestWatchman
The TestName Rule makes the current test name available inside test methods:
public class TestNameTest {
@Rule
public TestName name= new TestName();
@Test
public void testA() {
assertEquals("testA", name.getMethodName());
}
@Test
public void testB() {
assertEquals("testB", name.getMethodName());
}
}
TestName
public TestName()
starting
public void starting(FrameworkMethod method)
- Description copied from class:
TestWatchman
- Invoked when a test method is about to start
- Overrides:
starting
in class TestWatchman
getMethodName
public String getMethodName()
- Returns:
- the name of the currently-running test method