Questions tagged [spring-boot-test]

Spring Boot provides utilities and annotations to help when testing your application.

Spring Boot provides a @SpringBootTest annotation which can be used as an alternative to the standard spring-test @ContextConfiguration annotation when you need Spring Boot features. The annotation works by creating the ApplicationContext used in your tests via SpringApplication.

Utilities: ConfigFileApplicationContextInitializer,EnvironmentTestUtils,OutputCapture and TestRestTemplate

for example

EnvironmentTestUtils.addEnvironment(env, "org=Spring", "name=Boot");

Docs: https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html

1399 questions
0
votes
1 answer

WebTestClient does not work when using spring-webflux

I'm using Spring webflux via Spring boot 2.0.0.M3. Below is the dependencies of my project, dependencies { compile 'org.springframework.boot:spring-boot-starter-actuator', 'org.springframework.cloud:spring-cloud-starter-config', …
Kane
  • 8,035
  • 7
  • 46
  • 75
0
votes
2 answers

How to Test @HystrixCommand fallback method in Springboot Application

I am using @HystrixCommand as follows in a my method @HystrixCommand(fallbackMethod = "fallbackCircuit", groupKey = "group-key", commandProperties = { @HystrixProperty(name = "requestCache.enabled", value = "true"), …
0
votes
1 answer

Spring Boot Embedded Tomcat not starting when using with SpringBootTest

Currently I am trying to using SpringBootTest for Integration test along with Spring-cloud-contract, but for some reason I am not able to get the Embedded tomcat instance up and running. With Spring Boot Debug I am getting the following logs…
sagar27
  • 3,121
  • 3
  • 27
  • 37
0
votes
2 answers

Test Spring Cloud Streams with Spring Cloud Test

I have defined some streams producers (@Output) and consumers (@Input) in my spring boot application as long as my rest endpoints. Now I want to test both REST + Streams using @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment =…
salaboy
  • 4,123
  • 1
  • 14
  • 15
0
votes
2 answers

SpringBoot Starter Project - Error resolving template

I am writing a JUnit test, which should test the title of an html page. This project is a SpringBoot, Thymeleaf starter project. HtmlPath: private final static String HTML_PATH = "/pages/dashboard/dashboard.html"; JUnitTest: @Test public void…
invincibles04
  • 109
  • 3
  • 13
0
votes
1 answer

why spring boot test cannot recognise property value?

spring boot + jdbctemplate @Configuration public class MultiDBConfig implements BeanPostProcessor{ @Value("${spring.datasource.test-while-idle}") private boolean testWhileIdle; //... @Override public Object…
zhuguowei
  • 8,401
  • 16
  • 70
  • 106
0
votes
2 answers

Spring Boot Application is starting up from a JUnit test but unable to access through URL

I have a JUnit Test that starts my spring boot appcliation (Application.java). @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) public class AppclaitionTest { @Test public void contextLoads(){ …
Bhanuchandar Challa
  • 1,123
  • 2
  • 9
  • 17
0
votes
1 answer

org.dbunit.database.AmbiguousTableNameException: PROFIL thrown by my integration test

I am working with the following tables (I created a miniture of the DB cause it is so big) In my Integration test I configured DBUnit to work with the following data sources: @DbUnitConfiguration(databaseConnection={"mainDataSource",…
0
votes
1 answer

SpringBootTest support for running diffent SpringBoot Application Instances

With SpringBoot i can easily run the same Application as different instances with different configurations, for example: @SpringBootApplication @ComponentScan({"..."}) public class Application { public static void main(String[] args) { …
0
votes
2 answers

Null Pointer when using @SpringBootTest

I am using spring boot 1.4, when using the @SpringBootTest annotation for integration test, it gives a null pointer. @RunWith(SpringRunner.class); @SpringBootTest public class MyControllerTest { @Test public void mytest { when(). …
Jakim
  • 1,713
  • 7
  • 20
  • 44
0
votes
1 answer

Tree Component in Vaadin latest version doesn't work

I trying to use the Tree() method with last version of Vaadin inside my maven project with spring-boot to create a drop down simple menu, but I can't import the correct packages. I just have these dependencies in my pom.xml file:
Leo1234562014
  • 76
  • 2
  • 13
0
votes
1 answer

SpringBoot Test ContextConfiguration has no banner

I'm writing an integration testing framework, and in my parent test class I have the following: @ContextConfiguration(loader = AnnotationConfigContextLoader.class) public abstract class IntegrationTestParent extends AbstractTestNGSpringContextTests…
Niko
  • 4,158
  • 9
  • 46
  • 85
0
votes
1 answer

SpringBoot1.4-Unable to find@SpringBootConfiguration,use @ContextConfiguration/ @SpringBootTest(class) in test error when I run IntegrationTest

I am facing issue with Integration Test on one of Controller Test in SpringBoot 1.4. Below snippets will show a clear idea of project structure: class ExchangeControllerIT : public class ExchangeControllerIT extends AbstractSpringControllerIT…
0
votes
1 answer

Spring boot TestRestTemplate doesn't URL decode requestparam values

Setup: Spring Boot + SpringBootApplication; Spring Boot Test + TestRestTemplate for testing 1 endpoint, processed by method foo. input: 1 required request param (named q) that must be URL-encoded in the URI. output: (foo) just returns the string…
fabien
  • 1,529
  • 1
  • 15
  • 28
0
votes
2 answers

Unable to run Spring boot test runner with JPA without HSQL

We are trying to write test case for an application which works with both MyBatis and JPA in Spring boot using AbstractRoutingDataSource, Mockito; we are able to mock the mybatis code. When we integrate the JPA the @SpringBootTest trying to access…