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:

1677 questions
0
votes
1 answer

How to inject MockMvc in Spring Boot?

I am following this tutorial about integration test in Spring Boot: http://www.baeldung.com/spring-boot-testing Well, but when I try to Inject MockMvc I always get: Error creating bean with name 'mockMvcBuilder' defined in class path resource …
Leandro Borges Ferreira
  • 10,852
  • 8
  • 48
  • 69
0
votes
1 answer

@WebMvcTest for SOAP?

Is the Spring Boot annotation @WebMvcTest only intended for sliced RestController tests or should SOAP Endpoints be testable with it too? When I setup my test and run it, I only get a 404 response as if the endpoint wasn't there so I assume it…
user3105453
  • 1,589
  • 3
  • 25
  • 47
0
votes
1 answer

Spring Test ContextConfiguration inherit from Aplication context?

When loading a Spring Context for testing a Spring application e.g. something like this: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(loader = AnnotationConfigContextLoader.class, classes=MyTestConfig.class) public class SpringTest…
CodeClimber
  • 4,298
  • 8
  • 43
  • 53
0
votes
1 answer

Test spring boot app with servlet parameters in application.yml

In application.yml there is the following parameter: server: context-parameters: appCode: MYAPPCODE This parameter is read by a third-party library. When running on embedded Tomcat, the parameter is available in the ServletContext.…
0
votes
2 answers

Clear Spring application context after test

How can I clear the application context after each test execution, with Junit5 and Spring Boot? I want all beans created in the test to be destroyed after its execution, since I am creating the same beans in multiple tests. I don't want to have one…
Christina
  • 281
  • 5
  • 12
0
votes
1 answer

@DataJpaTest scanning entity of external jar

I have a multiple module project root +-- common +-- webProject And, I have tried to test on webProject @RunWith(SPringRunner.class) @DataJpaTest @SpringBootTest(classes = {XxxService.class}) public class XxxServiceTest { @Autowired …
0
votes
2 answers

Spring DataJpaTest do not load javax.transaction.SystemException with Java 9

I would like to test my service layer with DataJpaTest annotation. My setup is the following : SpringBoot 2.0.0-M7, JAVA 9 and pom xml : org.springframework.boot
0
votes
1 answer

SpringRunner initializing only given beans

I am trying to implement Spring integrations tests and I am thinking about two ways to go: For each test have different configuration and initialise only necessary beans for given test. This should mean the tests are isolated and the Spring context…
Vojtěch
  • 9,438
  • 25
  • 81
  • 138
0
votes
2 answers

Springboot Junit test NoClassDefFoundError EntityManagerFactoryBuilderImpl

I created a springboot (2) webflux project as follow : JPA Entity @Entity @Table(name = "users") public class User implements Serializable { ... } Spring repository public interface UserRepository extends CrudRepository
0
votes
1 answer

Making use of ReflectionTestUtils to mock a static class

I am writing unit test for a class which makes use of the static class ProcessTimer. To be precise, ProcessTimer.startTimer(). I am looking for a way to mock this call. I have used plain ReflectionUtils and PowerMock before, but I am wondering if I…
Johnu
  • 131
  • 1
  • 4
0
votes
1 answer

Test annotation processor with spring test

I am using junit to test my annotation processor. The test is failing. It seems like never entering the joinpoint, without any exception. My annotation is like this: @Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE…
S.min Chen
  • 53
  • 6
0
votes
2 answers

How to set the Environment variable in Spring

facing an issue when the code is trying to access the System.getProperty() in Spring Test cases. working when setting the VM argument on the test case that is running, but to run each test case class, have to set the VM argument explicitly. Is there…
murthy
  • 162
  • 4
  • 11
0
votes
1 answer

Topic not found error during application load test of a Spring Kafka application

I am using Spring Kafka 1.2.3 in an application developed with Spring Boot 1.5.8. As in many Spring application, I have a test that tries to verify the configuration of Component resolution made by Spring. The test is something similar to the…
riccardo.cardin
  • 6,393
  • 1
  • 45
  • 77
0
votes
1 answer

Spring test updates locally read JPA entity during transaction

I have a Spring integrated test that is wrapped in @Transactional. The Hibernate/JPA database interface extends JpaRepository and uses PESSIMISTIC_READ and PESSIMISTIC_WRITE locks on its functions. Within the test, the following steps occur: An…
wrapperapps
  • 752
  • 2
  • 14
  • 28
0
votes
2 answers

MockMVC returns 404 and pageNotFound warning in SpringTest

I have been researching for the past week and cannot find a explanation as to why my test case in springMVC is throwing a 404. It logs a warning that the page is not found. I quite certain that my config is correct and the application context is…
Corey Davis
  • 27
  • 2
  • 5
1 2 3
99
100