Questions tagged [junit-jupiter]

JUnit Jupiter is the combination of the new programming model and extension model for writing tests and extensions in JUnit 5.

Use the tag for questions that are specific to JUnit Jupiter.

Use the tag for all other questions related to features provided by JUnit 5 or migration to JUnit 5.

JUnit 5 Resources

263 questions
3
votes
1 answer

IntelliJ + JUnit 5 (Jupiter)

My build.gradle has: testCompile 'org.junit.jupiter:junit-jupiter-api:5.0.0' Using the standard example from http://junit.org/junit5/docs/current/user-guide/ import static org.junit.jupiter.api.Assertions.assertEquals; import…
clay
  • 18,138
  • 28
  • 107
  • 192
2
votes
0 answers

Testing a micronaut library

Recently I am using micronaut libraries to move some controllers which are meant to be reused. However, i cant figure out how to test those controllers. The get included in the application just fine, but on there own the tests case timesout. How can…
Friso Kluitenberg
  • 1,157
  • 1
  • 14
  • 34
2
votes
1 answer

Spring Starter Test - JUnit SpringBoot

Hello im new in testing and I first time trying to test a JpaRepository which interact with postgres in reality but in test it interacte with H2 Db i ve installed H2 dependencie and the software aswell but i still have a problem when using the…
Don Fleym
  • 27
  • 5
2
votes
3 answers

Prevent exception from being logged in test

I have a SpringBoot test which asserts an exception is thrown for certain situations from the method tested. However the method tested catches and groups multiple errors, logs the details and (re) throws just one 'ServiceException' instead. (log and…
Ville Myrskyneva
  • 1,560
  • 3
  • 20
  • 35
2
votes
1 answer

Maven build fails with failsafe plugin

I am trying to build my project and run the test by using junit5 and maven failsafe plugin for integration tests. If I run my test by using mvn failsafe:integration-test it runs all the integration tests. When I run maven install failsafe plugin…
user1474111
  • 1,356
  • 3
  • 23
  • 47
2
votes
1 answer

add JMH an existing spring boot project

I have tried multiple tutorials to make a poc using jmh inside my test package but always faced: No matching benchmarks. Miss-spelled regexp. My latest code: org.openjdk.jmh
Ed .d
  • 23
  • 1
  • 3
2
votes
1 answer

Could not find method testRuntime() for arguments [org.junit.jupiter:junit-jupiter-engine]

jdk 1.8. Gradle 7.3 In my java project I want to write unit test by Kotlin. So I try this: in build.gradle: plugins { id 'application' id "com.nocwriter.runsql" version "1.0.3" id 'idea' id "io.spring.dependency-management" version…
Alexei
  • 14,350
  • 37
  • 121
  • 240
2
votes
0 answers

How to mock static methods in Junit 5

I read a few threads here about static methods, and I think I understand the problems misuse/excessive use of static methods can cause. But I didn't really get to the bottom of why it is hard to mock static methods in JUnit5. I know in JUnit4 we can…
Akash Mishra
  • 31
  • 1
  • 3
2
votes
0 answers

Error TestEngine with ID 'junit-jupiter' failed to discover tests

I have the following error: 'org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests' when trying to run a test from the package with the structure test/java/mytest.class. I am using…
Hugo Prin
  • 31
  • 1
  • 3
2
votes
1 answer

Unit Testing Spring Boot API RESTful endpoints generated by Open API 3 YAML files

I have an application that is using Spring Boot (latest version) and creating a back-end that has RESTful api's. Traditionally, I have created controllers like: @RestController @RequestMapping("/contacts") public class ContactController { …
2
votes
2 answers

Junit 5 Test Suites

I'm trying to migrate a Project from JUnit 4 to JUnit 5.8.2 with junit-platform-suite-api 1.8.2. We used to organize our test classes in test suites. But if I use the @Suite annotation with @SelectClasses the test runner finds no test methods at…
René
  • 63
  • 7
2
votes
1 answer

Injecting Spring beans into a ParameterResolver in JUnit Jupiter

Trying to get Spring component (DataSource) autowired into JUnit ParameterResolver. But DataSource is not getting injected by Spring. I have registered the SpringExtension and also provided the context location…
rockycres
  • 71
  • 8
2
votes
2 answers

Injecting a bean into the context of a WebMvc test: @AutoConfigureMockMvc cannot be used in combination with the @Component annotation @Configuration

For my Java Spring test, I have decided to fake the system clock in order to make testing easier I have a test bean which inherits a common base class @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK) @AutoConfigureMockMvc(print =…
usr-local-ΕΨΗΕΛΩΝ
  • 26,101
  • 30
  • 154
  • 305
2
votes
2 answers

java.lang.NoSuchMethodError for Junit parameterized tests

I am trying to add some parameterized tests to my Spring Boot app and I am running into the below error. I have added the Maven dependency but I am still recieving this error ? Am i missing something ? I have read from other posts that the version…
user15613889
2
votes
1 answer

How to add matching rules to a PACT when using a PACT-builder?

Using the PACT-builder for consumer in a consumer-driven test, I try to build a pact and generate the contract as a json file (in a target folder by default). @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "foo-provider") class…
AVEH
  • 21
  • 2