Questions tagged [junit5]
Version 5 of the popular JUnit testing framework for the JVM. JUnit is a framework for writing repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks.
junit5
3,719
questions
0
votes
0
answers
18
views
ParameterizedTest JUNIT5 with suspend functions
I'm trying to clean a little bit my code and when testing my datasource I'm repeating a lot the test that returns connection and service error, and I'd like to have a bunch of code that tests ...
0
votes
1
answer
32
views
Mockito and Spring RestTemplate issue
I want to test this class :
public class TokenIntrospector {
private RestTemplate restTemplate;
private String userInfoUri = "http://localhost";
public TokenIntrospector(...
0
votes
2
answers
22
views
Harcoding PortNumber for mockserver using testcontainers
I am using testcontainers to create a mockserver in JUnit5.
It seems the port number changes for every run randomly, I want it to have a fix port number, which I will decide.
how this can be done ?
...
1
vote
1
answer
51
views
Junit 5 "ParameterResolutionException: Failed to resolve parameter [java.lang.String arg0]"
I want to test this constructor with different name parameters.
public Horse(String name, double speed, double distance) {
if (isNull(name)) {
throw new IllegalArgumentException("Name ...
-1
votes
0
answers
14
views
how to write junit test case for public method which internally call private method which is in same class [duplicate]
I have a publicMethod() and privateMethod,publicMethod() internally calls the privateMethod() and private method return a string in response.
how to write test case for such scenarios.
code:
class{
...
-2
votes
0
answers
23
views
Java CompletableFuture test exceptionally-block
i wanna test my "exceptionally"-Block of CompletableFuture.
I've already wrote a test, but is fails.
public CompletableFuture<Void> handleRequest(Request request) {
...
0
votes
1
answer
23
views
JUnit 5 - Migration - Custom test annotation no longer detected?
I had the following custom test annotation that worked in JUnit4 that IntelliJ and JUnit no longer wants to recognize:
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE })
@Retention(RUNTIME)
...
0
votes
1
answer
57
views
Out of Bound Exceptions
Please help me to solve the problem in selenium
java.lang.StringIndexOutOfBoundsException: Range [0, -1) out of bounds for length 7
code :
package adipolipkg;
import org.junit.Before;
import org....
0
votes
1
answer
34
views
Transactional (mybatis-cdi: org.mybatis.cdi.Transactional) annotation with rollbackOnly=true not rollbacking transactions inside a Weld / JUnit 5 test
I expect this class UserMapperTest.java to run the test rollbacking the transaction (in this case for a simple insert, where the field email is unique, but the core of the problem is about the ...
0
votes
0
answers
25
views
Intellij Idea: Unrecognized VM option 'UseSplitVerifier' While running Junit
Jdk: 17.0.1
Intellij: IntelliJ IDEA 2024.1.4
OS: Linux.
When I run Junit i see the error
Unrecognized VM option 'UseSplitVerifier'
That argument is not added in any of the configurations or pom.xml....
1
vote
0
answers
60
views
TestEngine with ID 'junit-jupiter' failed to discover tests in Maven configuration
I have a maven project with system and unit tests. I want to run JUnit plugin tests in headless mode. When I run the JUnit plugin tests from Eclipse using the option Run As -> JUnit Plugin Tests, ...
1
vote
1
answer
23
views
Java unit test failing due to null KeyHolder
I'm creating new unit tests for an application and I'm stuck because the KeyHolder is not returning a valid object.
For context, here are my classes:
ScriptDao class:
@Repository
public class ...
-1
votes
0
answers
44
views
Integration test not rollbacking database changes in Spring Boot 3.1.6 and JUnit 5
I have the following test:
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
class ForecastIntegrationTest {
@Autowired
private ...
0
votes
1
answer
45
views
junit 5 runs specific cucumber feature twice
Running Cucumber with JUnit 5 works ok as long as all feature files are run.
@Suite
@IncludeEngines("cucumber")
@ConfigurationParameter(key = Constants.FEATURES_PROPERTY_NAME, value = "...
0
votes
0
answers
34
views
Testcontainer Integration Test works with mvn verify but not within Eclipse
On linux fedora I have a JUnit 5 integration test that starts and uses a org.testcontainers.containers.PostgreSQLContainer
The test run successfully when using mvn clean verify
However, running them ...