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

How to migrate TestNG @DataProvider to JUnit Jupiter @ParameterizedTest

I have unit tests using TestNG that I try to move to JUnit Jupiter (JUnit 5), and I wonder which is the best way to do: TestNG: @DataProvider public Object[][] invalidPortNumbers() { return new Object[][] { { "--http", "" }, …
V-O
  • 123
  • 1
  • 5
6
votes
3 answers

@SpringBootTest not using test properties

I am using jasypt for encrypting application.properties in a Spring Boot application. My goal is to update my integration tests so that jasypt is used with test encryptor password. My problem is that my test is not overriding the test properties.…
2dor
  • 851
  • 3
  • 15
  • 35
6
votes
0 answers

How to upgrade JUnit version in Intelliji (from 4.11 to latest one)

It's not really coding question but I'm stuck on it. I start new Java project in Intelliji and add tests with JUnit5. In this tests I'm using @Role annotation for FakeSftpServerRule github library. I added all jupiter dependencies I just can thought…
AsfK
  • 3,328
  • 4
  • 36
  • 73
6
votes
3 answers

Junit5- jupiter all tests suite @BeforeAll @AfterAll not working

The before and after methods not working in JUnitPlatform. The code is below. import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.platform.runner.JUnitPlatform; import…
6
votes
2 answers

Practical uses for the option to pass `Supplier` as a message supplier in JUnit 5

The Assertions class in JUnit 5 allows for passing an Supplier as a messageSupplier, an object that provides the text of a message to report when the test fails. For example, assertEquals: public static void assertEquals​( char expected, …
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
6
votes
2 answers

JUnit5: Trouble Finding AssertEquals

I've set up JUnit in IntelliJ IDEA and have a bunch of tests with nothing in them. When I run them, they all pass as expected. However, when I type "assertEquals", it shows up in red. When I hover over it, it says "Cannot resolve method." I've…
anon_swe
  • 8,791
  • 24
  • 85
  • 145
5
votes
1 answer

Using Jupiter(Junit5) on instrumentation tests

I want to use Junit5 on instrumentation tests. When I add this line to Build.gradle androidTestImplementation "org.junit.jupiter:junit-jupiter:$junit_jupiter" My test showed the below error FAILURE: Build failed with an exception. What went…
Ali Doran
  • 378
  • 1
  • 12
5
votes
1 answer

How to mock ObjectMapper.readValue() using mockk

There was a similar question asked about Mockito here I have a situation where I would like to mock out readValue in the following line val animal: Animal = objectMapper.readValue(String(message.body)) I tried @Test fun `test you filthy animal`()…
Naruto Sempai
  • 6,233
  • 8
  • 35
  • 51
5
votes
1 answer

how to fix "The import org.junit.jupiter"?

I'm working on MMU project and I don't know how to fix this error on @Test annotation. How I can fix it? I have added JUnit library but that's not working.
user1773603
4
votes
1 answer

Using quarkus-jacoco for test that aren't annotated with @QuarkusTest

According to Quarkus Documentation, to have JaCoCo considering test classes that aren't annotated with @QuarkusTest, the only thing we need to do is to configure the jacoco plugin to execute the goal prepare-agent. I've added that, the same as the…
4
votes
4 answers

Junit 5 mockito unable to read properties file annotated with @Value in spring boot application

I am writing a junit test cases for one of component in spring boot application. That component is having @Value annotation and reading value from property file. When I am running my Junit 5 (mockito) and controls goes to the component; the value is…
DeskToDevelop
  • 439
  • 1
  • 5
  • 16
4
votes
1 answer

ParameterizedTest gets executed before @Before function

why parameterized tests are executed before setUp function? @Before public void setUp(){ System.out.println("some logic"); } @ParameterizedTest @CsvSource({"1997"}) void myTest(String arg) { …
kingGarfield
  • 304
  • 1
  • 12
4
votes
1 answer

JUnit5 not generating test-result TEST-*.xml that JUnit4 used to

When I used JUnit4 in my projects it seemed that each time a test ran, it would generate a TEST-*.xml report in app/build/test-result. Jenkins would use these XML reports to display failing and passing tests on each build. I've replaced JUnit4 with…
Programmer001
  • 2,240
  • 2
  • 19
  • 35
4
votes
1 answer

Powermock throws ClassNotPreparedException when using JUnit 5

I have a sample test class where I want to mock a static class.My build.gradle is like testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.2.0' testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params',…
Priya
  • 1,096
  • 4
  • 15
  • 32
3
votes
1 answer

JUnit Jupiter 5.10.0, failed to discover tests

After upgrading junit-jupiter-engine from 5.9.3 to 5.10.0 I started to get the following error. I'm running a Spring-Boot 3 application (spring-boot-starter-parent version 3.1.2). [INFO]…
João Pedro Schmitt
  • 1,046
  • 1
  • 11
  • 25
1
2
3
17 18