Saturday, 15 January 2011

java - Get currently executing @Test method in @Before in JUnit 4 -


I currently want to execute the test method in @ before so that I can get annotation current In law is executing.

  public class TestCaseExample {@Before public void setUp () {// Get the current method here. } @Test @MyAnnestation ("ID") Public Zero Some Test {// code}}    

Try the test name rule

  public class TestCaseExample {@Rule Public TestName testName = new TestName (); @ First public set up () {method m = TestCaseExample.class.getMethod (testName.getMethodName ()); ...} ...    

No comments:

Post a Comment