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.

junit
0 votes
0 answers
6 views

JUnit test failing Status expected:<201> but was:<404>

I've spent a lot of time trying to figure out this issue, but when I'm running my tests on my UserControllerTest class I'm getting Status expected:<201> but was:<404>. Here's my ...
dom's user avatar
  • 28
0 votes
0 answers
11 views

How to test flow paging data for an android application?

I'm currently testing repository class in my Android App, the function itself returns Flow<PagingData>. When I run the test it gives an error : After waiting for 1m, the test coroutine is not ...
RocketMan's user avatar
0 votes
0 answers
13 views

I'm trying to work testcode about Java Spring Boot 6.x Websocket code with STOMP but in trouble

public class WebSocketIntegrationTest { @LocalServerPort private int port; @Autowired private MockMvc mockMvc; @Autowired private ObjectMapper objectMapper; private ...
Buddhaman's user avatar
0 votes
1 answer
27 views

Playwright Junit file into X-ray

I am able to generate a results.xml file using playwright execution and also upload to JIRA. However, my screenshot/video from the execution are not reported back into X-Ray. I can see in xml file, ...
Libra's user avatar
  • 33
0 votes
1 answer
42 views

Group (or merge) @Unroll tests from Spock in JUnit XML result file

I have a Spock @Unroll test like this: @Unroll def 'A session uses the TLS protocol #enabledProtocolsOfSocket #protocolOfSession'() { given: // ... expect: // ... where: ...
crusy's user avatar
  • 1,492
0 votes
0 answers
26 views

How to write verify for static methods that have been called [in Mockito Core] [duplicate]

Without using PowerMockito and using Mockito-Core (the version of Mockito doesn't support PowerMockito and I cannot change the Mockito version), How can I verify that a call to a static method has ...
DropKick's user avatar
1 vote
0 answers
42 views

SpringBootTest with Togglz

I just recently added togglz to the spring-boot 3.1.9 application, which contains also much stuff like spring-security, spring-data, etc. Maven dependency: <dependency> <groupId>org....
Georgii Lvov's user avatar
  • 2,474
1 vote
0 answers
27 views

JerseyTest and Mockito - problem with mocking an object

My aim is to learn a little bit about mocking objects in the context of Jersey Test. I have 3 classes: ServiceController package com.vogella.jersey.first; import javax.ws.rs.*; import javax.ws.rs.ext....
lewap02's user avatar
  • 11
0 votes
0 answers
22 views

Dependency not getting mocked in unit test

I am trying to run a unit test for my springboot controller as: @WebMvcTest(controllers = MyController.class) @ExtendWith(SpringExtension.class) public class MyControllerTest { @Autowired ...
Mandroid's user avatar
  • 7,054
0 votes
0 answers
23 views

ParameterizedTest JUNIT5 with suspend functions

I'm trying to clean a little bit my code and when testing my datasource I'm repeating a lot the test that returns connection and service error, and I'd like to have a bunch of code that tests ...
StuartDTO's user avatar
  • 891
0 votes
0 answers
13 views

Junit expecting a 400 response but getting a 200

I am trying to test my springboot controller /save endpoint. I want to test that if you send a json request with a null agency name you should get back a 400 status and the response "Agency Name ...
Abby's user avatar
  • 9
0 votes
0 answers
40 views

Spring Boot microservices with JWT (Cannot run Integration test (401 Unauthorized Error))

I try to implement an example of Spring Boot microservices with JWT. I have some problem. I cannot run all integration tests of product service even if I defined bearer token in terms of admin and ...
jacksondel's user avatar
0 votes
1 answer
44 views

Stubbing error while mocking WebClient using Mockito

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

I cant init my webclient in a test with mockito

I'm working on a project with java spring boot 2.x and java 1.8. In my pom i got the dependencies of junit 4.13.2 and mockito 3.12.4. When i try to run my test i got the problem that my setup function ...
Juan Federico Di Leo's user avatar
0 votes
0 answers
44 views

How to mock Files API from java.nio.file.*

I am using Java nio API and have a below code, but unable to perform mocking on the below code. Path path = Paths.get(filePath); long sizeInBytes = Files.size(path); long recordCount = 0; try (Stream&...
PAA's user avatar
  • 11.5k

15 30 50 per page
1
2 3 4 5
1871