28,064 questions
0
votes
0
answers
21
views
Payara 7.2025.1 + payara-micro-managed + Arquillian + JUnit 5 - tests always pass outside container
I’m using Payara 7.2025.1 with payara-micro-managed, Arquillian, and JUnit 5. When I run my tests, a Payara Micro instance starts and deploys correctly, but it seems that the tests themselves are ...
2
votes
0
answers
32
views
@ParameterizedTest with @DatabaseSetup and @ExpectedDatabase
I have the following integration test which is setting up the database with @DatabaseSetup and checking that after doStuffThatAffectsTheDb() executes, the db has been modified as expected with @...
0
votes
0
answers
57
views
After upgrading mongodb to v5+ getting a "com.mongodb.MongoTimeoutException: Timed out.." in spring boot tests
Disclaimer: There are a couple of questions for this exact exception, sadly none of those match my environment or circumstances (thus i think this question is unique)
In my case i have a:
working ...
1
vote
0
answers
59
views
Is it possible to run spring boot test using junit console launcher?
I am trying to create a fat JAR that includes my application and its tests to run them externally using the JUnit Console Launcher. The build succeeds, and the JAR is created. However, when I execute ...
0
votes
1
answer
79
views
wiremock AutoConfigureWireMock HttpHostConnectException: Connection refused
@ActiveProfiles("it")
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ContextConfiguration(classes = ServiceApplication.class)
@AutoConfigureWireMock(port = 0)
@...
0
votes
0
answers
48
views
Its there anyway i can make a Exposed transaction on a separate thread share transaction resource with an outer transaction block
Basically i have a ktor exposed web app and i am trying to write this test and client.get("assets") fails to see the asset created in the outer transaction block. It tried to use what is ...
0
votes
1
answer
69
views
How to correct the build path for a JUnit Test Class in Eclipse? [duplicate]
I'm making a JUnit test class for a java class in Eclipse and I'm unsure of what steps to take to fix it.
I tried to add the JUnit 5 Library to the build path as part of "Fix project setup",...
0
votes
0
answers
30
views
How to get individual time for test methods when the test class times out (only class-level timeout info shown, need to identify slow test methods)
I am working with junit tests and I have a timeout on them (300s). But when the test timeout I get the information on class level. But I want information on individual test method on how much time it ...
2
votes
1
answer
78
views
How do I run java test suites in parallel with Gradle
I'm using the relatively new test suite plugin from Gradle: https://docs.gradle.org/current/userguide/jvm_test_suite_plugin.html.
I assumed that the different test suites, including the default test ...
0
votes
2
answers
123
views
@DisabledIf with jUnit depending on a string value in application.yml
I need to disable some unit tests depending on a string variable defined in my src/app/test/resources/application.yml.
ENVIRONMENT: local
I'm using Spring's @DisabledIf which takes a single ...
0
votes
1
answer
142
views
h2 db is empty on testing
I want to run tests on my app using h2 as a database but every time I attempt to run a test it shows me an exception saying that h2 db is empty. None of the related questions I`ve read helped me.
This ...
0
votes
0
answers
32
views
junit-standalone-console-platform problem with application.properties
I have a problem with reading application.properties by @SpringBootTest when I start it with a command:
java "-Dfile.encoding=UTF-8" "-Dallure.results.directory=config/reports/allure&...
0
votes
1
answer
102
views
Should JUnit tests crash instead of failing? [duplicate]
I'm writing a small app and have encountered the following issue:
@Test
public void givenSkiExists_whenAddingNewSki_thenThrowEntityAlreadyPresentException () {
skiManager.addEntity(new Ski(new ...
0
votes
2
answers
52
views
How to run tagged tests that are explicitly excluded in pom.xml?
This is part of my pom.xml:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.3</version>
<configuration>
<excludedGroups>slow<...
-3
votes
1
answer
352
views
How to JUnit Test Asynchronous CompletableFuture.runAsync code?
I want to test a method which asynchronously calls an API. Somewhat like below -
private void callExternalAPI(){
CompletableFuture.runAsync(() -> {
try{
//Calling the API
}...
0
votes
1
answer
43
views
How to go for JUnit testing for producing the test cases for the given program?
Suppose if you are going for the creation of test cases in VS code then how to build the test file for that by commands or built-in options ?
-1
votes
1
answer
48
views
How to test an API which has Oauth2 Resource Server
I got some problem with Junit (Spring Security 6.5), I have an API Register to testing which already work well when test with Postman (fully output), When test with Junit, I got test fail with error ...
0
votes
0
answers
52
views
Hibernate Shared Sessions
Since I migrated to Hibernate 6.x+ I started having problems with shared sessions in unit sessions.
I have a problem where I have the following structure:
I have a test that first creates a record (...
2
votes
1
answer
145
views
When performing integration tests for Springboot app with RestTemplate, why are not all returned values set?
I have a Springboot API that includes a model class Payment, a @Service class PaymentService, as well as a JPA repository, controller, and some utility classes. I have integration tests that mostly ...
2
votes
1
answer
69
views
ResourceBundleControlProvider not invoked when running program in an unnamed module under JUnit
When running a test program in an unnamed module under JUnit the ResourceBundleControlProvider.getControl() method is not invoked.
I have this implementation of ResourceBundleControlProvider:
...
0
votes
1
answer
48
views
No constructor in tested class that can be satisfied by available tested/injectable
Goal:
TC need to pass
Using:
junit 4.12
jmockit 1.54
Adopt JDK 21
test case Code:
public class UTBOMRetrievalDAO {
@Tested
BOMRetrievalDAO bomRetrievalDAO;
@Injectable
ServerContext ...
0
votes
1
answer
187
views
Repeated parameterized test with JUnit 5 / Jupiter
I want to repeatedly execute the following test class:
class Test {
static Foo foo;
@BeforeAll
static void setUpAll() {
foo = generateRandomFoo();
}
@ParameterizedTest
...
1
vote
1
answer
85
views
Tests not running with JUnit, with no errors nor log either
My JUnit tests simply aren't running. When I tried, nothing happened. JUnit displayed 0/0 tests run, and there were no logs nor errors in the console
I checked the different possible causes in this ...
0
votes
0
answers
63
views
How to run unit tests for teamcity BuildTypes created by Teamcity Kotlin DSL
We are using Teamcity Kotlin DSL to create our buildings in TeamCity and writing some unit tests for the build types. In the build.gradle.kts , we have added the dependencies as followed:
dependencies ...
0
votes
1
answer
304
views
JUnit not recognized in VS Code anymore after reopening project (no green triangle icons)
I'm trying to run JUnit tests in Visual Studio Code without using Maven or Gradle, just using plain .java files and .jar libraries.
Project Setup:
I'm using VS Code with the Java Extension Pack, and ...