Skip to main content
Filter by
Sorted by
Tagged with
1 vote
0 answers
41 views

The test file is: @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = BeanTestConfig.class) class TestWithSeparateBeanConfig { @MockBean BeanOne beanOne; @Autowired ...
tm1701's user avatar
  • 7,723
1 vote
1 answer
403 views

I am writing a test in Flutter using mockito, I want to mock Riverpod's Provider, but I get an error and can't solve it. The various versions are as follows # pubspec.yaml environment: sdk: ^3.5.2 ...
akkie's user avatar
  • 13
0 votes
1 answer
49 views

I am currently facing an odd behavior during my test, The goal was to test the following registration method : @RestController @RequiredArgsConstructor public class RegisterController { ... ...
newenpoi's user avatar
0 votes
0 answers
141 views

I have the following @RequestMapping public interface ExcludesOverriddenController { @RequestMapping(value = "excludes/overridden", method = RequestMethod.GET) @ResponseStatus(value = ...
JGleason's user avatar
  • 4,020
1 vote
0 answers
262 views

I have an utility class ConverterUtil with a method convertJsonToFileBytes and two test classes(WorkflowExportServiceTest,WorkflowExportControllerTest). If I run the test classes individually ...
Aldo Inácio da Silva's user avatar
0 votes
1 answer
46 views

I am testing disposal of a JDialog extension. However, even though I am certain the dialog has no error in that regard, I can't yet get my test to pass. It seems dispose() is invoked, but not on my ...
Cagepi's user avatar
  • 329
0 votes
0 answers
48 views

So I'm struggling with writing a mockito test method for a method having this piece of code Future<?> future = executor.submit(() -> { try { ...
Bhavya Sai Kamasamudram's user avatar
-1 votes
1 answer
46 views

I have some java base class that has inside 1 method: public class SB { @SneakyThrows public Document downloadHtml(String url) { return Jsoup.connect(url) .userAgent(&...
Krzysztof Czeronko's user avatar
0 votes
1 answer
191 views

I am setting up tests using Groovy and the Spock framework. My tests depend on the passage of time, and the services in question use new Date() for some rules. Because of this, I would like to modify ...
felipe mota effting's user avatar
0 votes
0 answers
121 views

Rewrite JMockit Mockup to Mockito: Interception of method calls of dependency api I try to rewrite JMockit code (new Mockup) to Mockito. In my JUnit test a method (initializeEntityManagerInterception) ...
PeterPan333's user avatar
0 votes
2 answers
727 views

I have multiple Spring Boot tests where I need to override a bean that is loaded in the test context using the @SpringBootTest annotation. In one of my test classes, I successfully used the @MockBean ...
rasilvap's user avatar
  • 2,219
-1 votes
1 answer
76 views

I am trying to write a unit test (using Mockito) for my Spring Security config class and it has this code @Bean public GrantedAuthoritiesMapper authoritiesMapper() { return (authorities) -> { ...
XAJA's user avatar
  • 37
-1 votes
1 answer
55 views

I need to mock a static method, so that it throws an exception the first time it is called, and returns some value, the second time it is called. I know how to mock it so that it throws an exception ...
Sandeep Barnabas's user avatar
0 votes
1 answer
56 views

I have a test class which I want to test for JPA query. @SpringBootTest @DirtiesContext class JPAUnitTest { @Autowired private OrganizationRepository organizationRepository; @Autowired ...
titanium's user avatar
0 votes
3 answers
117 views

I'm getting mockito exception when doing the stubbing: @Mock RetryTemplate retryTemplate; @Test public void testSubmitCreditTransaction() { when(retryTemplate.execute(any())).thenAnswer(...
techie11's user avatar
  • 1,425
0 votes
1 answer
148 views

I am working on a unit test for a Spring Boot application. I have a MetricsLogger DI that work fine in the service code, but failed to pass the unit test as it's null in the test. Despite using @...
MusicalChicken's user avatar
0 votes
1 answer
649 views

We have code that executes RestTemplate.exchange() to execute an HTTP request, and a Unit Test that tests it. The expected params (5) are @Override public <T> ResponseEntity<T> exchange(...
gene b.'s user avatar
  • 12.6k
0 votes
1 answer
61 views

I have a simple spring boot app with controller (example) @RestController @RequestMapping("/person") public class PersonController { @Autowired PersonService personService; @...
Kris Swat's user avatar
  • 1,094
-1 votes
2 answers
272 views

I'm testing a function like this: public class CsvUtilsTest { @Mock private S3Client s3Client; @Mock private S3BucketWrapper s3Buckets; @Mock CsvMapper csvMapper; @...
Joe C.'s user avatar
  • 501
0 votes
1 answer
342 views

I'm writing a test for a method that throws various exception. This test case is to throw SQLException and I noticed these behavior. @Test public void testGetPreparedStatement_throwsSQLException() ...
Sither Tsering's user avatar
1 vote
2 answers
88 views

I'm writing a Unit Test for a Class (CustomHttpClient) that internally uses a library (java.net.http.HttpClient) to make an external HTTP call. Being it a Unit Test, I would mock the internal ...
javacomelava's user avatar
0 votes
2 answers
66 views

I'm writing a Flutter test where I'm trying to mock a method that calculates the BMI. Despite using when(...).thenReturn(...) to return a future value, I'm encountering the following error: ══╡ ...
pekran123 pekranian's user avatar
0 votes
0 answers
50 views

How to write assert or verify for these. I cannot change the code in any way. Only Junit can be written by me. public void Calculator(booker, product) { Matcher matcher = buildCriteria(product); ...
DropKick's user avatar
0 votes
1 answer
267 views

Based on answers to previous questions like these, I am trying to mock WebClient in a unit test. Please note that I don't wish to use WireMock or MockWebserver. source method: public class ...
Kaliyug Antagonist's user avatar
-1 votes
1 answer
53 views

I am encountering an intermittent issue with my unit tests for a Spring service where the method under test occasionally returns null. This issue is random and affects different methods during the act ...
Burckhardt Sébastien's user avatar