public class

TestName

extends TestWatchman
java.lang.Object
   ↳ org.junit.rules.TestWatchman
     ↳ org.junit.rules.TestName

Class Overview

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());
 	}
 }
 

Summary

Public Constructors
TestName()
Public Methods
String getMethodName()
void starting(FrameworkMethod method)
Invoked when a test method is about to start
[Expand]
Inherited Methods
From class org.junit.rules.TestWatchman
From class java.lang.Object
From interface org.junit.rules.MethodRule

Public Constructors

public TestName ()

Public Methods

public String getMethodName ()

Returns
  • the name of the currently-running test method

public void starting (FrameworkMethod method)

Invoked when a test method is about to start