org.junit.rules.TestName Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truffle-tck Show documentation
Show all versions of truffle-tck Show documentation
A collection of tests that can certify language implementation to be compliant
with most recent requirements of the Truffle infrastructure and tooling.
The newest version!
package org.junit.rules;
import org.junit.runner.Description;
/**
* 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
*/
public class TestName extends TestWatcher {
private String fName;
@Override
protected void starting(Description d) {
fName = d.getMethodName();
}
/**
* @return the name of the currently-running test method
*/
public String getMethodName() {
return fName;
}
}