spring-test Questions

6

Solved

So I am getting this error in my Spring boot Gradle project: 'java.lang.AutoCloseable org.mockito.MockitoAnnotations.openMocks(java.lang.Object)' java.lang.NoSuchMethodError: 'java.lang.AutoClosea...
Kaveri asked 7/5, 2021 at 9:13

3

Solved

My gateway will redirect traffic to many different services (under different domain names). how can i test the gateway's configuration? with only one service i can just setup the mock server (like ...
Harumscarum asked 20/1, 2020 at 14:51

7

Solved

How can I tell the @Sql annotation to run only once for the class, and not for each @Test method? Like having the same behaviour as @BeforeClass? @org.springframework.test.context.jdbc.Sql( scri...
Mages asked 12/12, 2017 at 14:56

7

Solved

I am using Spring for MVC tests Here is my test class @RunWith(SpringRunner.class) @WebMvcTest public class ITIndexController { @Autowired WebApplicationContext context; MockMvc mockMvc; @...
Gabriella asked 18/9, 2016 at 5:0

2

Solved

I have a particular class (let's say MyTest) in my Spring integration tests that is using PowerMock @PrepareForTest annotation on a Spring component: @PrepareForTest(MyComponent.class). This means ...
Brothel asked 1/9, 2016 at 16:55

27

Solved

I wan to implement a Junit 5 test into Gradle project. I tried this: Gradle configuration: plugins { id 'org.springframework.boot' version '2.5.5' id 'io.spring.dependency-management' version '1....
Schoolmate asked 22/12, 2021 at 17:5

10

Solved

I'm using MapStruct, mapstruct-jdk8 version 1.1.0.Final and defining abstract class that I inject via Spring. I'm looking at how to be able to test them via Junit Test ? I've basicaly a main mappe...
Oralee asked 24/7, 2017 at 8:13

2

I am using Mockito to mock spring beans. It works fine when I mock an interface. In our application, there are few @Component beans which do not implement any interface. When I try to mock such ...
Ecclesiology asked 5/2, 2017 at 7:8

2

I have the next configuration in my unit Test: @SpringBootTest(webEnvironment = WebEnvironment.NONE) @TestPropertySource(locations="classpath:itest.properties", properties = "server....
Rushton asked 31/3, 2022 at 20:18

3

Solved

I have a spring-boot application for which am trying to create unit testcases. Below is the code that I am trying to run, I don't have any configuration file that I have (used only annotations) so ...
Talie asked 11/9, 2018 at 10:40

7

The error show up when My code like this: @Test public void getTemplateByIdTest() throws Exception { client.get().uri("/template/getTemplate/7") .exchange() .expectStatus().isOk() .expectHeade...
Counterfoil asked 25/7, 2018 at 8:30

4

Solved

I am using Liquibase in my Spring web application. I have a bunch of entities with hundreds of tests for REST APIs in the integration tests for each entity like User, Account, Invoice, License etc....
Sprang asked 24/10, 2016 at 3:21

2

I am setting up an Spring boot application on Jenkins. For the unit tests i am getting below error. This error is not particular to one test cases. Every time I run it is giving me error for differ...
Taxis asked 19/10, 2018 at 18:31

10

Solved

I'm writing my unit tests using JUnit, PowerMock, Spring Test and an in-memory H2 database. When I run the tests from Intellij everything runs correctly. But when I run the tests from maven (either...
Halfcock asked 8/3, 2017 at 18:37

7

I'am trying to do a simple Integration test using Spring Boot Test in order to test the e2e use case. My test does not work because I'am not able to make the repository saving data, I think I have ...
Nord asked 27/4, 2017 at 13:0

4

Solved

I have several integration tests running on Spring Framework that extend the base class called BaseITCase. Like this: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {AppCa...
Litman asked 9/8, 2017 at 9:49

9

Solved

How do I configure my Spring Boot application so that when I run unit tests it will use in-memory database such as H2/HSQL but when I run Spring Boot application it will use production database Pos...

17

Solved

I have a very simple test case that is using Mockito and Spring Test framework. When I do when(pcUserService.read("1")).thenReturn(pcUser); I get this exception. org.mockito.exceptions.misusi...
Kasten asked 8/2, 2012 at 1:24

4

Solved

On my spring boot application I want to override just one of my @Configuration classes with a test configuration (in particular my @EnableAuthorizationServer @Configuration class), on all of my tes...
Phylis asked 19/8, 2016 at 14:27

12

Solved

For my Spring-Boot app I provide a RestTemplate though a @Configuration file so I can add sensible defaults(ex Timeouts). For my integration tests I would like to mock the RestTemplate as I dont wa...
Rossanarosse asked 2/3, 2016 at 9:18

1

Given the following class definition: @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = Application.class) @DirtiesContext(classMode =...
Refresh asked 3/2, 2017 at 9:18

3

With Spring Boot 2.1 I am defining a RedisCacheManager bean in a configuration file, with Java configuration. Everything works correctly but I would like sometimes to disable it, for instance in th...

3

Solved

I have an abstract class annotated with @Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts="someScript") . I have a test class which inherits from the abstract class. The child clas...
Anaheim asked 2/9, 2016 at 15:47

20

I have written some JUnit tests using JUnit 4 and spring-test libraries. When I run the tests inside Eclipse then run fine and pass. But when I run them using Maven (during the build process), they...
Antihelix asked 29/7, 2010 at 18:5

4

Solved

I've been trying to test out @TransactionalEvents (a feature of Spring 4.2 https://spring.io/blog/2015/02/11/better-application-events-in-spring-framework-4-2) with our existing Spring JUnit Tests ...
Sherri asked 10/4, 2016 at 22:50

© 2022 - 2025 — McMap. All rights reserved.