All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.junit.rules.TestName Maven / Gradle / Ivy

There is a newer version: 2.12.15
Show 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 name; @Override protected void starting(Description d) { name = d.getMethodName(); } /** * @return the name of the currently-running test method */ public String getMethodName() { return name; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy