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

Spring conversion service not getting initialized correctly for test

I am using spring boot 1.5.9 to write a small rest server. I have just started of with initialization code and got stuck with this weird behavior. I have a small test - @RunWith(SpringRunner.class) @SpringBootTest public class TestMongo { …
user1676688
  • 334
  • 2
  • 14
0
votes
1 answer

Exception While Running SpringWS JUnit Test : java.lang.IllegalStateException: Failed to load ApplicationContext

I am getting an exception when I try to run the Spring Web Service JUnit Test Using the Spring WebService ServerSide Integration Test using MockWebServiceClient. When I run the WebService (Not Test), it is running fine but when I run the Junit…
greencheese
  • 514
  • 7
  • 23
0
votes
1 answer

spring how to use one web-environment for multiple test

I got multiple REST APIs with multiple path. I´m currently testing those APIS with junit using the web-environment of spring to setup a http server. So I use a class which contains the following anotation and injects the…
monti
  • 411
  • 5
  • 19
0
votes
1 answer

Spring Boo DAO Testing: How do I ensure a Mongo index is used?

In a Spring Boot web environment, our integration tests use an integrated Mongo engine (currently flapdoodle oss embedded mongo). I want to construct a way to make sure that the queries in our repository stack are utilizing the indexes that we have…
IcedDante
  • 4,991
  • 10
  • 49
  • 81
0
votes
1 answer

Spring PropertySource is not loaded in tests

I have a spring @Component class which is used to load properties from a .properties file in the classpath. The class looks like: @Component @ConfigurationProperties("mail") @PropertySource("classpath:config.properties") public class MailProperties…
nikkatsa
  • 1,661
  • 4
  • 25
  • 42
0
votes
1 answer

@Repository Not Being Autowired in @DataJpaTest with multiple @Configuration files being imported in one Configuration file

I have three @Configuration files, as follows: MessageGatewayConfiguration.class @Configuration @EnableAutoConfiguration @EnableJpaRepositories(basePackages = { "xyz.idtlabs.smsgateway.*" }) @EntityScan(basePackageClasses = { …
Usman Khaliq
  • 313
  • 3
  • 16
0
votes
1 answer

How to get Spring Boot default validation reponses in @WebMvcTest?

When I run my application and there is a validation problem with the request to one of my endpoints, the response has a lot of information on what exactly went wrong. It looks similar to this: { "timestamp": "2017-11-23T13:18:05.923+0000", …
Wim Deblauwe
  • 19,439
  • 13
  • 111
  • 173
0
votes
2 answers

Autowired bean in spock test null after downgrading spring from 4.3.x to 3.2.x

I downgrade my application from spring 4.x to 3.x and now when I fire simple test in spock which using autowired bean, this bean is null. @ContextConfiguration(classes = Configuration.class) class SomeTestClass extends Specification { …
Kamil W
  • 1,689
  • 9
  • 35
0
votes
0 answers

Issue when testing Spring framework

I need to add unit testing to my Spring project. I'm currently using spring framework within JAX-RS, but I'm unable to test it. My pom.xml is as follows:
FVod
  • 1,955
  • 3
  • 17
  • 41
0
votes
1 answer

How to test the @RequestBody of a @RestController with junit?

I want to write a simple test for one of my @RestController and assert that the input @RequestBody has been properly mapped to the PersonDTO: @RestController public class PersonServlet { @PostMapping("/person") public PersonRsp…
membersound
  • 66,525
  • 139
  • 452
  • 886
0
votes
2 answers

Spring boot websocket test

I have a spring boot project with websocket and I want to test the project sending multiple request to the socket from different users. I want to use threads to imitate the users that send data from the web app but I don't know exactly how to make…
duricu vlad
  • 147
  • 1
  • 12
0
votes
2 answers

JUnit Mock test returns null on using InjectMocks

I am trying to unit test my service class but the mock returns null package com.tgt.store.pricetask.pricetask_service; import com.tgt.store.pricetask.model.PriceTaskMaster; import com.tgt.store.pricetask.model.TaskModel; import…
Venky
  • 567
  • 2
  • 8
  • 22
0
votes
2 answers

In mvn test, Spring-test throws sql script errors in mvn test

I have three test cases. They each execute successfully when run individually through RunAs > JUnit and mvn individual test case runs. But when I run mvn test on all three together, the first two test cases execute properly, and the 3rd test…
JamesD
  • 449
  • 5
  • 23
0
votes
0 answers

Spring TestExecutionListeners and execution order

I use Spring + TestNg + Spring Test DBUnit. Right now I ran into the issue that Spring Test DBUnit @DatabaseSetups annotation is executed early than TestNG @BeforeMethod annotation. I need to change this behavior to let methods annotated with TestNG…
alexanoid
  • 19,599
  • 35
  • 160
  • 321
0
votes
1 answer

Test DB with TestNG not rolling back

I am trying to do some basic automated testing with a DB and TestNG and it isn't working. First run succeeds as I expect, 2nd one doesn't because the first one never rolled back. I have looked at several places for examples and it seems to be…
Christian Bongiorno
  • 3,923
  • 1
  • 25
  • 65
1 2 3
99
100