How to implement custom runner in JUnit5

Is there a way to have complete control over the execution of test methods (including before / after methods) in JUnit5, similar to the JUnit4 @RunWith annotation)?

I am trying to build a JUnit5 Arquillian extension, but since Aquillian basically needs to run every test in the container, I am having trouble starting Arquillian from the Junit5 extension.

My code is here: BasicJunit5ArquillianTest.java

The test should run all methods (including before / after) in a separate container, which can be a separate JVM, a remote or embedded server, or something isolated. My extension launches a test method from beforeEach hook, using Arquillian to transfer the test class and run it in the container using LauncherFactory.create () , collect test results and pass them back.

The problem is that the test methods are executed twice - through normal JUnit5 execution and through my Arquillian extension from the beforeEach hook. I would like to run tests only through Arquillian and skip the normal execution of methods.

Is this possible in the JUnit5 extension? Or do I need to create my own test engine, possibly expanding the Jupiter test engine?

+4
source share
1 answer

There is no extension point ( yet ?) That allows you to determine where and how tests are performed. This is already true for threads, which means there is no way to run them in a JavaFX or Swing EDT application thread.

You may have to go deeper and implement the engine , but that means users have to choose between writing Arquillian tests or writing Jupiter tests.

+2
source

Source: https://habr.com/ru/post/1674450/


All Articles