Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [junit]

Popular unit testing framework for Java and Scala. The latest version, JUnit 5, supports rich annotation-based and parameterized tests. Consider using in conjunction with the Java or Scala tag to indicate your use case.

1 vote
1 answer
56 views

Testing Routes with Spring Boot und JUnit

Hello I really need help testing my routes (if that is even a good practice). Setup: Spring Boot JUnit Vaadin I want to test my protected routes, which only admins should be able to get access to. ...
chris's user avatar
  • 11
-1 votes
1 answer
32 views

Mocking the new instance creation call inside a void method without using PowerMock

I have a class where inside a void method it does a new instance creation public class BaseDao { protected void setDataSource(DataSource dataSource) { this.defaultTemplate = new ...
Plainsage's user avatar
  • 145
1 vote
2 answers
124 views

Testing Dispatcher IO and ViewModelScope in Unit Tests

I'm trying to test some code in my viewmodel. I'm trying to make two network calls with dispatcher async, but haven't figured out how to test. This is a simplified example of what I'm essentially ...
keyboard_user's user avatar
0 votes
0 answers
63 views

How to throw exception with super constructor been mocked

I have an exception class public class FooStudioException extends SpamException { public FooStudioException(String message, String localizedMessage, Throwable cause) { super(...
Abhijit's user avatar
  • 63.3k
0 votes
2 answers
87 views

Running a Single Parameterized Test with Maven in JUnit 4

I'm trying to run a specific parameterized test method (xyzIT#testTaskRestarts) from a JUnit 4 test class using the Maven Surefire Plugin, but I'm encountering issues. With the base command being set ...
Sangeet's user avatar
  • 1,026
-3 votes
1 answer
64 views

My when(...).thenReturn(...) is not working [closed]

I'm making some test but my mocking is not working. This is my test class. @UnitTest @RunWith(MockitoJUnitRunner.class) public class ResendMailingStrategyUnitTest { @Test public void sendTest(...
Nicolas Villacorta's user avatar
0 votes
0 answers
22 views

Unit testing class with flow collection in init

How can I best go about unit testing flows that are collected in a class's init function? The only solution I've come up with so far requires hard-coded delays. Consider a sample implementation of a ...
Henrik Klev's user avatar
0 votes
0 answers
34 views

Mock WebClient webflux bean with Qualifier

I have the following scenario: A config class with two WebClient beans with different names public class WebClientConfig { @Bean("bean_1) public WebClient getWebClient1(WebClient.Builder ...
Gabriel García Garrido's user avatar
0 votes
1 answer
81 views

Unable to pass multipart file through mockMvc

I am writing junit test for my request method. Im using mockMvc to trigger the rest request. When I run my test I get the error java.lang.NullPointerException: Cannot invoke "org.springframework....
manjosh's user avatar
  • 564
2 votes
1 answer
88 views

Cannot run explicitly tagged test only in Kotest

I have a spring boot project which uses kotlin version 1.7.0. My pom looks something like below. <properties> <kotlin.version>1.7.0</kotlin.version> ... </<...
Risalat Zaman's user avatar
0 votes
0 answers
127 views

Kotlin Coroutines Test: UncompletedCoroutinesError - Test Coroutine Not Completing

I'm encountering an UncompletedCoroutinesError while running a Kotlin coroutine test. The specific error message is: kotlinx.coroutines.test.UncompletedCoroutinesError: After waiting for 1m, the test ...
Kotiswar Kaithepalli's user avatar
0 votes
1 answer
36 views

Configure xunit output of Testem in Ember.js

I use Ember 5.6.0. Running ember test --silent --reporter xunit > ember-test-result.xml outputs an XML with the following content: <testsuite name="Testem Tests" tests="439" ...
crusy's user avatar
  • 1,492
0 votes
1 answer
28 views

No error message provided by the last invocation of @RetryingTest

I have a test like this (language is Kotlin): @TestInstance(TestInstance.Lifecycle.PER_CLASS) class MyTest { private var i: Int = 0 @RetryingTest(3) fun go() { Assertions....
Boris's user avatar
  • 1,116
0 votes
0 answers
32 views

Junit for GCS files reading in spring boot

I have an application in spring boot where I am fetching multiple files from GCS and then iterate to read file content. I am able to mock gcs storage but not able to mock the file content. I want to ...
Invoice Testing's user avatar
0 votes
0 answers
19 views

Maven Surfire plugin duplicates retried tests in Test-*.xml

In the current project, skipped and failed tests are retried twice. A test is removed from the test results if it was skipped or failed the first time to avoid duplication. public void onFinish(...
Yaryna's user avatar
  • 370

15 30 50 per page