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

Testing Spring Service class that extends abstract class and interface

I want to mock my service class and call any methods that it inherits from abstract class and interface like they belong to the service. Unfortunately, when I mock service and call methods from abstract class, then mockito calls real methods in…
0
votes
1 answer

Reload Spring application using DirtiesContext annotation doesn't work with nested classes

I can't reload my spring application after each test into my nested classes: /*...*/ @DirtiesContext( classMode = AFTER_EACH_TEST_METHOD ) public class MyTestClass { @Nested class MyNestedClass_1 { @Test void test_1() { …
Zrom
  • 1,192
  • 11
  • 24
0
votes
1 answer

What is the equivalent of Cucumber BDD scenario examples feature in JUnit 5 (JUnit Jupiter)?

How do I setup my test class so I can run the same set of tests for multiple scenarios using JUnit 5? For example, I need to run the same test case for different user accounts by passing the account usernames into login text field as a parameter on…
rusmusus
  • 21
  • 1
  • 5
0
votes
1 answer

@ContextConfiguration in test if parent has @ContextHierarchy

I have tests for class, that uses RestTemplate. Now I need to write another test for the similar class. I've decided to move @ContextHierarchy to separate interface like below @ContextHierarchy({ @ContextConfiguration(classes = { …
RomanMitasov
  • 925
  • 9
  • 25
0
votes
2 answers

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: Invalid use of argument matchers! 2 matchers expected, 3 recorded

I know that it has been asked multiple times on this platform. I also checked the solution provided that either use all raw parameters or all Matcher arguments. In my case Argument Matcher(any, anyString) has been used for all parameters but still…
Manish
  • 1,274
  • 3
  • 22
  • 59
0
votes
1 answer

Integration tests fail with gradle test but pass with IDE

I keep getting exceptions in all integration tests, while unit tests run fine. All exceptions look like this: UsersControllerTest > getOneUser() FAILED java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:132 …
Alisher
  • 480
  • 5
  • 16
0
votes
0 answers

java parameterized unit tests with jupiter: better reference to test data sets

For a gradle based side track project I moved from junit4 to junit5(jupiter) which allows much more flexibility when writing parameterized tests. That's great. There is however one annoying details which makes debugging tests cumbersome: unlike the…
arkascha
  • 41,620
  • 7
  • 58
  • 90
0
votes
0 answers

JUnit Jupiter 5.5.1 depends on JUnit Platform 1.3.2?

I have an impression that JUnit Jupiter 5.5.1 does not like JUnit Platform 1.3.1. If both are specified in gradle dependency, then all JUnit 5 tests would just be ignored. See my previous SO Q&A on this. For example, I think the following…
leeyuiwah
  • 6,562
  • 8
  • 41
  • 71
0
votes
1 answer

Is there any way to test the order of Lists / Collections with jUnitJupiter?

I'm using JunitJupiter for unit testing. Now I'm at a point where I don't know how to check the order of a list. Code: @Test @DisplayName("Should be in ascending order") void sortAscending() { List> finalList =…
Hubi
  • 440
  • 1
  • 11
  • 25
0
votes
1 answer

Why when use transform construction with pd.Series i'm getting Error: Mismatch Length

I have a big pandas.DataFrame (~2.5 million rows) with 10 columns. I need to fill column noshow_label, i group data by column event_label and if in column event_action there is a value no_show then i need to paste True else i need paste False. To do…
Kralon
  • 9
  • 6
0
votes
1 answer

SpringBoot Junit5 fails when renaming package of class holding @SpringBootApplication annotation

I'm struggling with JUnit 5 when moving the @SpringBootApplication to a different package. I have setup a new SpringBoot-project (2.2.1.RELEASE) with Maven and Eclipse (had to upgrade this from "Eclipse Photon" to support the SpringBoot-Release My…
Ulrich
  • 715
  • 2
  • 7
  • 25
0
votes
0 answers

JUnit5 (aggregator) provides old dependencies

I am using JUnit5 aggregator: org.junit.jupiter junit-jupiter 5.5.1 test But when I show my dependency tree, I see old…
All_Safe
  • 1,339
  • 2
  • 23
  • 43
0
votes
1 answer

Why attribute of test class becomes null between 2 tests?

THE CONTEXT: I tried to create a junit test which represents a user guide of my reader. So to do that, I create an init method, a test which test my assumption: resources are initialized, create a reader and finally read file content. (The second…
Manucci
  • 1
  • 4
0
votes
1 answer

ClassExtensionContext can't be found in Junit 5 Jupiter version 5.4.0-RC1

Up to now I worked with Junit Jupiter 5.4.0-M1. Now I want to upgrade to the version 5.4.0-RC1. Unfortunately my program doesn't compile anymore because (among others) the class ClassExtensionContext couldn't be found anymore. Does anyone know the…
Christof Nasahl
  • 229
  • 3
  • 6
0
votes
2 answers

Is it possible to combine 'JGiven Spring' with 'JGiven JUnit 5'?

Unfortunatly spring beans are not autowired with my approach. I used version 0.17.0 of JGiven. The following Test fails with a NullPointerException because spring bean 'messageService' in class HelloWorldStage is null. Gradle: testCompile group:…
Cengiz
  • 5,375
  • 6
  • 52
  • 77
1 2 3
17
18