springboottest

以下是为您整理出来关于【springboottest】合集内容,如果觉得还不错,请帮忙转发推荐。

【springboottest】技术教程文章

java – 用于非spring-boot应用程序的@SpringBootTest【代码】

我正在使用spring-rest,spring-data-jpa等创建一个非spring-boot应用程序,我想使用spring boot(1.4.1.RELEASE)进行集成测试.请注意,我在任何地方都没有SpringApplication类或@SpringApplication注释 在我的测试课上我有@RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = MyConfiguration.class) public class MyIT { }@RestController public class MyControl...

java-具有MockMvcBuilders独立设置的SpringBootTest尽管设置了它却没有加载我的ControllerAdvice【代码】

我正在创建这样的控制器和控制器建议: 测试类别:@RunWith(SpringRunner.class) @SpringBootTest public class TestController {private MockMvc mockMvc;@Mockprivate MyService myService;@Autowired@InjectMocksprivate MyController myController;@Beforepublic void setup() {MockitoAnnotations.initMocks(this);//Build the controller mock handlermockMvc = MockMvcBuilders.standaloneSetup(MyController.class).setCon...

java-SpringBootTest-如何在运行时配置中替换一个bean?【代码】

我正在为Spring Boot应用程序编写集成测试.只要我使用100%运行时配置进行测试,一切都会顺利进行.但是,当我尝试仅为该bean提供一个自定义bean时,一切都会中断.@RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class CombinedControllerIntegrationTest2 {@TestConfiguration static class ContextConfiguration {@Bean@Primarypublic SolrDocumentT...

java-@SpringBootTest的一次性配置【代码】

如何引导我的Spring Boot 2集成测试,以便在所有这些测试中,我可以拥有一组配置,这些配置可以在测试数据库中预先植入一些可以在所有集成测试中使用的测试数据?解决方法:假设您正在使用h2测试数据库. 我的src / test / resources / application.properties文件具有:spring.jpa.hibernate.ddl-auto=create-drop您将需要一个具有以下结构的配置文件. (这是一个位于src / test / java文件夹中的配置示例):@Profile("test") @Configur...