Questions tagged [junit5-extension-model]

1

votes
0

answer
165

Views

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 org.junit.jupiter.api.Test; import org.junit.jupiter.api.exten...
Starkadur
1

votes
0

answer
25

Views

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 Logger log = LoggerFactory.getLogger(getClass()); @Override...
elonderin
1

votes
0

answer
30

Views

How to run all tests in same webdriver session using selenium-jupiter junit5 extension [closed]

While using Selenium-Jupiter, a custom junit5 extension for Selenium, every tests create its own webdriver session and close it once test complete Any possibility to run all tests in same webdriver session ? Here both tests run in different webdriver sessions. I need to run both in same webdriver se...
Amit
1

votes
1

answer
260

Views

Set parameter to JUnit5 extension

I wonder how to configure an extension by a test. Scenario: The test provides a value that should be used inside the extension. Current Solution: The value is defined as field inside the test and used by the extension thru scanning all declared fields and pick the correct one (reflection). Problem:...
R4FT3R
1

votes
1

answer
198

Views

Is there a Neo4j test harness that uses the JUnit 5 Extension Model?

In writing test cases for Neo4j I would like to move onto using just the JUnit 5 Extension Model and not use org.junit.vintage or junit-jupiter-migrationsupport. Currently I can only find the Neo4j test-harness for JUnit 4 which uses TestRule and is dependent on org.junit.vintage and junit-jupiter...
Guy Coder
0

votes
0

answer
19

Views

How execute code after each dynamic test?

There is a test: package com.cdek.qa_auto.config; import com.cdek.qa_auto.utils.CdekJUnitListener; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DynamicTest; import org.junit.jupiter.api.TestFactory; import org.junit.platform.launcher.Launcher; import org.junit.platform.launc...
1

votes
1

answer
0

Views

TempDirectory extension: is there a replacement for createInCustomDirectory() methods?

There used to be createInCustomDirectory() methods in TempDirectory extension class in JUnit 5.4.0-M1 (see docs). The main use case for those methods was to change tmp dir used by the extension. In the final release (5.4.0) TempDirectory extension was made private and enabled by default and those me...
Andrey Pechkurov
2

votes
0

answer
17

Views

Extension lifecycle and state in JUnit 5

User guide contains following: Usually, an extension is instantiated only once. It's not very clear when extension can be instantiated many times? I'm supporting test suite with multiple extensions and every extension stores it's state in class fields. Everything works fine, but can I rely on this o...
Sergey Guriev
3

votes
1

answer
511

Views

JUnit 5, pass information from test class to extension

I am trying to write an extension for Junit5 similar to what I had for Junit4 but I am failing to grasp how to do that in the new (stateless) extension system. The idea in the previous version was that user could pass information into extension class and hence change the way it behaved. Here is a ps...
Siliarus
2

votes
5

answer
1.3k

Views

JUnit5 - How to get test result in AfterTestExecutionCallback

I write JUnit5 Extension. But I cannot find way how to obtain test result. Extension looks like this: import org.junit.jupiter.api.extension.AfterTestExecutionCallback; import org.junit.jupiter.api.extension.TestExtensionContext; public class TestResultExtension implements AfterTestExecutionCallback...
bugs_
2

votes
1

answer
210

Views

How to create custom JUnit5 Extensions

Is it possible to create a custom extension like I could've created a @Rule in JUnit4? public class MockMetadataServiceRule extends ExternalResource { @Override protected void before() throws Throwable { //some setup } @Override protected void after() { // some teardown } } Then, I can do this wi...
LazerBanana
4

votes
3

answer
207

Views

Check that JUnit Extension throws specific Exception

Suppose I develop an extension which disallows test method names to start with an uppercase character. public class DisallowUppercaseLetterAtBeginning implements BeforeEachCallback { @Override public void beforeEach(ExtensionContext context) { char c = context.getRequiredTestMethod().getName().charA...
Roland Weisleder
4

votes
2

answer
71

Views

What is the equivalent of @RuleChain in JUnit 5?

I have 2 'class level' rules : MyRule1 and MyRule2 MyRule2 depends on MyRule1 MyRule1 'before' method should therefore run before the MyRule2 'before' method. In JUnit 4, it can be implemented this way, via the RuleChain : static MyRule1 myRule1 = new MyRule1(); static MyRule2 myRule2 = new MyRule2(...
Baptiste Le Bail