Questions tagged [spring-test]

`spring-test` is the testing module of the Spring Framework, providing support for unit and integration testing with JUnit and TestNG, including various mocks for unit testing and the Spring TestContext Framework & the Spring MVC Test Framework for integration testing Spring-based applications.

spring-test is the testing module of the core Spring Framework, providing support for and and based applications with and , including mocks for things like the and APIs, the Spring TestContext Framework, and the Spring MVC Test Framework.

Online Resources:

Related Tags:

2041 questions
0
votes
1 answer

Spring Test H2 Flyway - error in sql statement

I have the following sql migration, that doesn't work with h2. If I remove the following SQL - everything works fine. How can i solve it? SQL State : 42001 Error Code : 42001 Message : Syntax error in SQL statement "CREATE TABLE…
0
votes
0 answers

AssertionError: expected:<8089> but was:<-1>

My application is running in local, I am trying to do Spring Rest Controller testing. It is running in 8089 port. In application.yml spring: profiles: active: sit In application-sit.yml server: port: 8089 servlet: context-path:…
Sun
  • 3,444
  • 7
  • 53
  • 83
0
votes
1 answer

How to run the SpringBootTest with only a single bean and with included resilience4j annotations

I would like to run an integration test of a single bean with resilience4j annotated method in a spring boot app. My intent is to test resiliency of bean method calls while not loading the full spring context. The setup is as follows: Dependencies…
miro
  • 131
  • 2
  • 9
0
votes
0 answers

Spring Boot Send Outlook Email

I'm trying to send an email when my batch job fails. I think I have everything but it keeps giving me a null pointer exception when I get to the send email line of my test class. package utilities; import org.junit.jupiter.api.Test; import…
skigdmg
  • 3
  • 3
0
votes
2 answers

Mockito failing inside internal call for mocked method

I'm trying to mock the return value for a method using the when call from mockito. However, I'm new to this and I may perhaps be misunderstanding how mockito works, since the call is failing inside the method mocked when that calls another method. I…
Francislainy Campos
  • 3,462
  • 4
  • 33
  • 81
0
votes
1 answer

Test Spring boot rest api but output not excepted

i just learn about spring mock test and run a simple rest api app with spring mocktest in maven test and eclipse IDE, but my output is 400 but my api run ok in PostMan and reactjs, i use security too but i dont think i should it here here is my api…
0
votes
1 answer

What does Spring Boot test documentation mean?

Spring Boot test documentation says: If your test uses one of Spring Boot’s test annotations (such as @SpringBootTest), this feature is automatically enabled. To use this feature with a different arrangement, listeners must be…
LiLi
  • 391
  • 3
  • 11
0
votes
1 answer

@CurrentSecurityContext always inject null in mockMvc integration tests?

I am using the spring security annotation @CurrentSecurityContext to inject the authentication object. This works well when the application is running, but in a @SpringBootTest it always injects null, even when using @WithMockUser. When adding…
0
votes
1 answer

How to make a request file to be executed before another in WireMock?

I have 2 json files for sending request: First: "request": { "method": "GET", "urlPathPattern": "my/url/([url0-9/-]{13})", "queryParameters": { "type": { "equalTo": "xxx" } } } Second: "request": { …
0
votes
1 answer

How to test HandlerInterceptor's postHandle method springboot

I have some logic inside the interceptor's postHandle method to expose a header value to the my front end angular application. My question is how to test interceptors? public class CustomResponseInterceptor implements HandlerInterceptor { …
softechie
  • 97
  • 2
  • 10
0
votes
1 answer

SpringBoot Test doesn't load Tomcat

I am trying to test my SpringBoot Application. When I start it as usual it starts the Tomcat Service as expected and loggs it into the console after the Spring Logo. When I execute @SpringBootTest Classes however, it appearently doesn't start the…
Mars
  • 21
  • 5
0
votes
1 answer

Is there a way for @SpyBean to create spies for all types based on the interface type in a Spring Boot test?

I have a Spring Boot application where I would like to ensure that a list of decorators are verified to be executed. These decorators all extend from the same Abstract class, which in turn extend from the same interface, and they are autowired into…
JCB
  • 341
  • 5
  • 18
0
votes
1 answer

Why does @WebMvcTest not load Controller-Advices into the Application-Context?

Helloin my parameterized junit5-test i get a NestedServletException until i add the @ContextConfiguration-Annotation above my test class in which i reference my custom exception handler that is annotated with @ControllerAdvice. In it i have methods…
Nico S.
  • 77
  • 1
  • 1
  • 9
0
votes
1 answer

spring boot & Spock

I have a springBootVersion = '2.3.2.RELEASE' app and I would like to use Spock for my unit and integration tests. I have this for Spock in my Gradle: testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude…
sonoerin
  • 5,015
  • 23
  • 75
  • 132
0
votes
1 answer

How to write Junit for constructor injection of beans

I have build a kind of handler pattern which gives me specific handler types based on input parameter. The autowiring is at constructor level, which fills the container(HashMap) with respective Strategy beans. Here is the code. How can I assert this…
mitali
  • 87
  • 8
1 2 3
99
100