程序包 org.junit.rules
类 TestName
- java.lang.Object
- org.junit.rules.TestWatcher
- org.junit.rules.TestName
- 所有已实现的接口:
TestRule
public class TestName extends TestWatcher
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()); } }
- 从以下版本开始:
- 4.7
构造器概要
构造器 构造器 说明 TestName()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 String
getMethodName()
protected void
starting(Description d)
Invoked when a test is about to start
构造器详细资料
TestName
public TestName()
方法详细资料
starting
protected void starting(Description d)
从类复制的说明:TestWatcher
Invoked when a test is about to start- 覆盖:
starting
在类中TestWatcher
getMethodName
public String getMethodName()
- 返回:
- the name of the currently-running test method