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
1
vote
1 answer

junit5: howto introspect if a test is actually augmented with @Before/AfterEach methods

I'm writing a little extension that tells me in my log when a test starts, so i know which logs are related to which tests: public class LoggingExtension implements Extension, BeforeEachCallback, AfterTestExecutionCallback { protected final…
elonderin
  • 509
  • 4
  • 12
1
vote
0 answers

JUnit Pioneer TempDirectory extension: Failed to resolve parameter

I'm trying to make a tempDirectory using the JUnit Pioneer (version 0.3.0) TempDirectory extension to use in unit tests with JUnit Jupiter API (version >= 5.1.1.). Environment: IntelliJ IDEA 2017.2.4 jdk1.8.0_191.jdk MacOS 10.14.1 import…
Starkadur
  • 63
  • 3
1
vote
1 answer

How to return value to @Test from junit extension?

I have tests with allure2 @Tmslink("1234") annotaion on each @Test. So, i need to get @TmsLink value and use it in my tests. I've got annotation value in extension, but how can i provide it to test? public class TmsLink implements…
newSqlz
  • 133
  • 8
1
vote
1 answer

Configuration of a JUnit 5 extension

I am upgrading an internal tool based on JUnit 4 to JUnit 5. Therefore I have to write an extension for the test execution. The task of the extension should be to ensure the correct state of external application (start it if it is not running etc.).…
Oliver
  • 3,815
  • 8
  • 35
  • 63
0
votes
1 answer

JUnit5 - customised lifecycle events/extension points

I am writing an acceptance test suite in Junit5. I'd like to generate customised output (html) specific to my domain as a result of this. This output will contain data that is obtained from lifecycle events such as test started (or before all tests)…
Kannan Ekanath
  • 16,759
  • 22
  • 75
  • 101
0
votes
1 answer

Is there a way to access values of a custom annotation in a ExecutionCondition of junit 5 tests?

I have the following annotation to mark test code that should not be executed if a server does not listen on a host and port each specified in a properties file: @Target({ ElementType.TYPE, ElementType.METHOD…
r-uu
  • 423
  • 1
  • 4
  • 18
0
votes
0 answers

JUnit 5 extension for starting Tomcat 9 with codehaus cargo fails

I fail to use a Tomcat container with codehaus's cargo-maven3-plugin in version 1.10.7. It's using Java 11. When I execute the code that follows I get this exception which seems to me that downloading and installing the Tomcat container works. The…
jmizv
  • 1,172
  • 2
  • 11
  • 28
0
votes
1 answer

Preventing parallel execution for Spock and JUnit5 platform

I maintain a tool that acts as a JUnit5 platform test runner. When it is supplied with Spock tests, I'd like to prevent them from running in parallel, regardless of the options set by the user. For Jupiter tests this can be done by setting a system…
henry
  • 5,923
  • 29
  • 46
0
votes
0 answers

Apply JUnit 5 Extensions to specific package with tests

In my project, I have both API and UI tests, which are in different packages. I am using JUnit 5 as the test runner with some extensions for UI tests. I have property junit.jupiter.extensions.autodetection.enabled=true which means, that all…
0
votes
2 answers

JUnit5: Before and After Suite method invocation

I've spent a few days trying to find out a solution, so I know all the basic answers I've read the documentation, and I know, that @BeforeClass/@AfterClass is replaced with @BeforeAll/@AfterAll, @RunWith no longer exists; superseded by…
0
votes
1 answer

Sandboxed tests with Junit5 (Is Junit4 @RunWith more powerful compared to Junit5 @ExtendWith)

So with Junit4 I was able to run tests with my own runner via @RunWith annotation. This was super powerful and allowed me to use my own "special" class loader for each test. This "special" class loader job was to reload a subset of classes when…
0
votes
0 answers

Does Invocation#skip() skip all remaining interceptors too?

JUnit 5's InvocationInterceptor.Invocation#skip() method's documentation says: Explicitly skip this invocation. I find this a bit unclear. Suppose the invocation represents a test method. Suppose further there are two interceptors registered. …
Laird Nelson
  • 15,321
  • 19
  • 73
  • 127
0
votes
0 answers

Is there a way to defer parameter resolution?

(I'm reasonably sure the answer is "no", but I want to make sure.) In JUnit 5 you can write an extension that is an implementation of ParameterResolver. Before your test runs, if the method in question has parameters, then an extension that…
Laird Nelson
  • 15,321
  • 19
  • 73
  • 127
0
votes
1 answer

JUnit 5: under what conditions is ExtensionContext.getTestMethod() not available?

I'm working on a JUnit 5 extension where I am using the ExtensionContext.getTestMethod() to extract an annotation from test methods. Optional testMethod = context.getTestMethod(); if (testMethod.isPresent()) { MyAnnotation annotation =…
armandino
  • 17,625
  • 17
  • 69
  • 81
0
votes
1 answer

JUnit5 - conditional using of extension

Is it possible to use extension depending on some condition in JUnit5? I have extension that collect and send test run results to external service (TestRail). But I want to have it enabled for remote runs and disabled for local runs. E.g. something…
Arrovil
  • 865
  • 1
  • 8
  • 20