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

Is JUnit Engine required for your test suite to run?

Does a test suite requires junit-jupiter-engine as a dependency, or junit-jupiter-api is enough? Under a post in Stack Overflow - Difference between junit-jupiter-api and junit-jupiter-engine, I have found that both dependencies are essential for…
Kaloyan
  • 41
  • 1
  • 6
1
vote
0 answers

JUnit 5: react on Exception from Extension (Callback)

In my Tests I have several Extensions via the *Callback Implementation. (BeforeAllCallback, BeforeEachCallback, ....) And I want to react on specific Exceptions from the implementation of the Callbacks. e.g. The Callback tries to report some…
markus
  • 31
  • 1
  • 3
1
vote
0 answers

Is it possible to have an assertion in the @AfterAll method?

I would like to have an assertion in the @AfterAll method after aggregating data from a @ParameterizedTest. Unfortunately, it doesn't work because the exceptions thrown within the @AfterAll method are not propagated up. class ExampleTest { …
armandino
  • 17,625
  • 17
  • 69
  • 81
1
vote
1 answer

How to write a test for a service in which beans self-register

Problem with correct class setting for tests. I have the following service structure My service: Interface public interface ColumnsFromTableService { List getTableColumnsFromSource(DataProvider dataProvider, String tableName); …
Nicolas
  • 11
  • 3
1
vote
1 answer

Wiremock verify doesn't work if run together with other integration tests

I'm not an expert with Wiremock and probably there's something wrong in my settings/configuration but I'm facing a weird scenario when it comes to verify a specific test. if I run this specific test among the whole IT suite, the test fails on…
Maxuel
  • 127
  • 10
1
vote
0 answers

JUnit5 - Execute first parameterized test in parallel then going sequential

I want to implement the following scenario. Starting with a list of arguments passed into a first test in my class that should run in parallel, i then want to switch to sequential behavior for very single argument passed to the first test. Given the…
Bernado
  • 548
  • 1
  • 6
  • 18
1
vote
2 answers

Selenium4+Junit5 : Infinite browsers are launching while running scripts in Parallel with Selenium 4

I have well configure and designed framework using webdrivermanager = '5.0.3'( Selenium 3.141.5,) + Junit 5 + junit-platform.properties file to run the test scripts in parallel, which running seamlessly without any issues. I am able to run scripts…
sam
  • 289
  • 7
  • 19
1
vote
1 answer

Why doesn't @DirtiesContext work in Spring Boot JUnit5(Jupiter) ? (OOM)

I have a couple of integration in this fashion: @SpringBootTest @ExtendWith(SpringExtension.class) @AutoConfigureMockMvc @ActiveProfiles({"test", "test-batch"}) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) class…
1
vote
0 answers

How to control logging level for conditionally skipped unit tests in Maven / Surefire

I have some JUnit unit tests which are annotated like this to be executed only if there is a specific system property defined. Usually, those tests are only executed on demand by a developer on the local machine by enabling the property, but are not…
Software Craftsman
  • 2,999
  • 2
  • 31
  • 47
1
vote
1 answer

Junit tests are failing after I upgrade the spring boot dependencies

I have the following code that is running fine when I had spring boot dependencies 2.3.3. class Details { String pin; State state; } class DetailsDto { String pin; StateDto stateDto; } class State { } class StateDto { } @Named class…
Naren
  • 139
  • 1
  • 17
1
vote
0 answers

Gradle JUnit/Jupiter testing - Setup specific contexts per test classes groups?

The application I am working on requires that different contexts are created depending on the JUnit tests to be run. Specifically, say I have five test classes - ClassOneTest.class, ClassTwoTest.class, ..., ClassFiveTest.class. I also use the…
1
vote
2 answers

TypeError: unhashable type: 'numpy.ndarray' in Python program

Here is my code: dic = test_dataset.class_indices idc = {k:v for v, k in dic.items()} img = load_img( r'C:\Users\sreep\Downloads\Alzheimer_s Dataset\test\NonDemented\26 (62).jpg', target_size = (224,224,3)) img = img_to_array(img) img =…
Sridara Pavan
  • 11
  • 1
  • 2
1
vote
1 answer

Junit Jupiter 5.8.x ClassOrder

I'm trying to order some class tests so Test_Class_1 will run before Test_Class_2. I saw a few post about Jupiter 5.8.0 can do it. It seems to be pretty straightforward, but could not make it work. I'm following the…
1
vote
1 answer

Got LazyInitializationException in jupiter @BeforeAll method

In my integration tests I would like to populate my system with some data in advance that I can rely in my test cases, with @BeforeAll (see below). package com.ksteindl.chemstore.service; import org.junit.jupiter.api.BeforeAll; import…
1
vote
0 answers

Why test functions do not access in memory database?

I am writing a test for MongoRepository custom functions class. Here are repositories functions that I need to test: public interface DataRepository extends MongoRepository { List getBySizeId(String sizeId); List
Michael
  • 13,950
  • 57
  • 145
  • 288