Questions tagged [junit5-extension-model]

Use this tag only for JUnit 5 or any versions thereafter and when related to the Extension Model created for JUnit 5. AKA JUnit Jupiter Extension Model, JUnit labmda Extension Model.

The JUnit 5 Extension Model replaces the @Rule and @ClassRule with a new model for extending test.

References:

JUnit 5 User Guide - Extension Model

75 questions
0
votes
1 answer

How do I use the junit5 platform launcher api to discover tests from a queue?

I'm looking to distribute tests to multiple instances of the junit5 standalone console whereby each instance reads off of a queue. Each instance of the runner would use the same test.jar on the classpath, so I'm not trying to distribute the byte…
Damon
  • 305
  • 1
  • 5
  • 13
0
votes
1 answer

JUNIT 5 Automatic Extension Registration | How to create Extensions file inside META-INF/services folder and what is the folder structure?

I'm confused after reading JUnit 5 document Junit Automatic Extension Registration Specifically, a custom extension can be registered by supplying its fully qualified class name in a file named org.junit.jupiter.api.extension.Extension within the…
0
votes
1 answer

Assert System.out/err in testcase

I'm looking at porting an old junit4 extension to junit5 by creating an extension. One feature that I'm thus far failing on is to fail any test method that writes on System.out or System.err, and have the failure point to that specific test. I tried…
chris_s
  • 1
  • 1
0
votes
0 answers

Change container TestExecutionResult in a HierarchicalTestEngine

Note: if you have never seen test engines, you might be very confused at the beginning (at least it was for me). There is an example here. In JUnit5 it is possible to create a custom TestEngine that can discover and execute tests (not only the…
Marco Luzzara
  • 5,540
  • 3
  • 16
  • 42
0
votes
1 answer

initializationError FAILED java.lang.ExceptionInInitializerError at TestWithResourcesExtension.java

Trying to retrieve data from a JSON file but facing the below issue while retrieving data. import com.adelean.inject.resources.junit.jupiter.TestWithResources; import com.adelean.inject.resources.junit.jupiter.WithGson; import…
SeleniumUser
  • 4,065
  • 2
  • 7
  • 30
0
votes
2 answers

Type mismatch junit5 @ExtendWith

so this is probably a really dumb question but I just started to migrate a project from junit 4 to 5 and saw that @RunWith() does not longer exists. It is replaced by @ExtendWith. So I tried to do it like this: import…
sunxca
  • 85
  • 1
  • 1
  • 6
0
votes
1 answer

How can I control how many JUnit5 Test Instances are going to be generated in Runtime and apply separate ParameterResolver to each of the instance

I'd like to execute Selenium Grid tests using Maven like this: mvn verify-Dtest=BaseTest -Dprop.selenium.server.url=http://localhost:4444/wd/hub -Dprop.browser=chrome -Dprop.version=80.0.3987.106 I inject ChromeDriver into Test constructor using…
Paulus
  • 138
  • 1
  • 11
0
votes
1 answer

How to create a test for a custom ParameterResolver implementation?

I've created a ParameterResolver implementation in order to inject a parameter into my test methods. I have a scenario where the instantiation of the parameter object could fail without some proper parameters defined by the correspondent annotation…
Cristiano
  • 1,414
  • 15
  • 22
0
votes
0 answers

how to use @Mock and @Autowired in Junit5 unit test?

I want to use both @Autowired and @Mock. For Example, I don't want to mock conversionService, I want to autowire it and mock other services.
0
votes
0 answers

JUnit extension export in maven plugin

I created a JUnit extension in a maven plugin project and I want to use this plugin and the JUnit extension in another project, but I have no idea how can I export and import dependencies of the maven plugin and the JUnit extension. I tried to…
0
votes
0 answers

Make JUnit5 test method thread safe using Spring Beans

I am trying to run JUnit 5 tests in parallel using Spring framework. I have a singleton bean: WebDriver that needs to be injected in about 4 places(POJO classes). Then a test-class will inject some of these POJO classes to run the test…
0
votes
0 answers

How to get a list of all my custom annotations on all test methods within a BeforeAllCallback Extension?

What is a clean way to get a list of all my custom test method annotations of all to-be-executed test methods in a Jupiter BeforeAllCallback Extension? The Extension shall collect setup data from these custom annotations on the test methods, and…
leo
  • 3,528
  • 3
  • 20
  • 19
0
votes
1 answer

JUnit 5 Jupiter tags using extension

All my DB tests are annotated with a custom DbExtension extension. I want to also tag these tests so I can run them separately in the CI. Is there anything I can add on the extension class so that it will tag all extending tests? just to illustrate…
LiorH
  • 18,524
  • 17
  • 70
  • 98
0
votes
1 answer

How to create Extension which runs beforeAll only once for whole big class with many nested classes inside

Given my tested class with many nested classes inside: class TestWithManyNested { @RegisterExtension static MyExtension extension = new MyExtension(); @Nested class Nested1 { @Test void nested1() { } …
0
votes
1 answer

How to manage lifecycle of instances with TestInstanceFactory?

I'm using JUnit 5.3.0-RC1, trying to implement an extension for the new TestInstanceFactory interface. (I want to get the objects from Weld for CDI injection etc.) If I implement TestInstanceFactory I can create my own instances. If I also implement…
seanf
  • 6,504
  • 3
  • 42
  • 52
1 2 3 4
5