Package org.junit.rules
Class TestName
java.lang.Object
org.junit.rules.TestWatcher
org.junit.rules.TestName
- All Implemented Interfaces:
TestRule
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());
}
}
- Since:
- 4.7
-
Field Details
-
name
-
-
Constructor Details
-
TestName
public TestName()
-
-
Method Details
-
starting
Description copied from class:TestWatcherInvoked when a test is about to start- Overrides:
startingin classTestWatcher
-
getMethodName
- Returns:
- the name of the currently-running test method
-