1

How can I invoke JUnit core to start a test run, and inject a custom @Test method?

I know that by using

JUnitCore junit = new JUnitCore();
Result result = junit.run();

I can start a JUnit test run and get the final result, and I know that by adding a RunListener I can get a method call on each phase of execution - Is there any way to break this down further into the individual Before / Test / After calls?

In addition, is there a way that I would be able to substitute a method to be run instead of the given @Test method definition?

The context of the question is that there is an automation test base that has large overlap with a manual test base - whose testing can share the same @Before, and @After events, and only the @Test methods would be substituted; this would greatly ease the load on the manual testers.

I would like to be as non-intrusive to the existing test base as possible.

Short of re-rolling my own JUnit framework, would there be a way to, even using reflection, substitute each test method?

Community
  • 1
  • 1
Matt Clark
  • 27,671
  • 19
  • 68
  • 123

0 Answers0