1

One answer to question Get name of currently executing test in JUnit 4 states that you should subclass BlockJUnit4ClassRunner to get the name of the currently executed JUnit4 tests. It also says that you need some "kung fu" to get the name out of the runner.

My idea is that the test class gets a reference to its runner instance and asks for the name. But how to get the reference to the instance?

(Or: is there a better way of kung fu?)

Eclipse Luna 4.4.1 installation says, I'm using JUnit 4.11.0.v201303080030

Community
  • 1
  • 1
Ulrich Scholz
  • 2,039
  • 4
  • 30
  • 51
  • If you want just the name of the test you could use this http://stackoverflow.com/questions/17232715/get-currently-executing-test-method-in-beforein-junit-4 – Morvader Oct 08 '14 at 07:31
  • `@Rule public TestName testName = new TestName();` does not work for me. `testName` is always `null` – Ulrich Scholz Oct 08 '14 at 12:13

0 Answers0