spring-test

Test the SpringBoot application startup

天大地大妈咪最大 提交于 2020-12-30 08:07:38
问题 I have a JUnit test that starts an spring-boot application (in my case, the main class is SpringTestDemoApp ) after the test: @WebIntegrationTest @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = SpringTestDemoApp.class) public class SpringTest { @Test public void test() { // Test http://localhost:8080/ (with Selenium) } } Everything works fine using spring-boot 1.3.3.RELEASE . Nevertheless, the annotation @WebIntegrationTest and @SpringApplicationConfiguration

Test the SpringBoot application startup

喜夏-厌秋 提交于 2020-12-30 08:02:43
问题 I have a JUnit test that starts an spring-boot application (in my case, the main class is SpringTestDemoApp ) after the test: @WebIntegrationTest @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = SpringTestDemoApp.class) public class SpringTest { @Test public void test() { // Test http://localhost:8080/ (with Selenium) } } Everything works fine using spring-boot 1.3.3.RELEASE . Nevertheless, the annotation @WebIntegrationTest and @SpringApplicationConfiguration

How can Spring's test annotation @Sql behave like @BeforeClass?

核能气质少年 提交于 2020-12-02 07:10:11
问题 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( scripts = "classpath:schema-test.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD ) public class TestClass { @Test public void test1() { //runs the @Sql script } @Test public void test2() { //runs the @Sql script again } } 回答1: You can't do that out-of-the-box. The @Sql annotation only has two

Spring boot ComponentScan excludeFIlters not excluding

我是研究僧i 提交于 2020-11-30 11:11:34
问题 I am having a SimpleTest : @RunWith(SpringRunner.class) @SpringBootTest(classes = SimpleTestConfig.class) public class SimpleTest { @Test public void test() { assertThat(true); } } and a configuration for this test : @SpringBootApplication @ComponentScan(basePackageClasses = { SimpleTestConfig.class, Application.class }, excludeFilters = @ComponentScan.Filter( type = FilterType.ASSIGNABLE_TYPE, classes = Starter.class)) public class SimpleTestConfig { } I am trying to exclude the Starter

Spring boot ComponentScan excludeFIlters not excluding

强颜欢笑 提交于 2020-11-30 11:07:28
问题 I am having a SimpleTest : @RunWith(SpringRunner.class) @SpringBootTest(classes = SimpleTestConfig.class) public class SimpleTest { @Test public void test() { assertThat(true); } } and a configuration for this test : @SpringBootApplication @ComponentScan(basePackageClasses = { SimpleTestConfig.class, Application.class }, excludeFilters = @ComponentScan.Filter( type = FilterType.ASSIGNABLE_TYPE, classes = Starter.class)) public class SimpleTestConfig { } I am trying to exclude the Starter