8得票1回答
Spring Boot集成测试在连续运行后失败

我有一个Spring Boot集成测试和一个Spring Boot Web集成测试。当分别运行这两个测试时,它们都通过了。但是作为一套测试运行时,第二个执行的测试总是失败的。每个测试都启动(并关闭)我的应用程序,并依次使用我的 `h2` 数据库。我尝试交换测试的顺序,并且总是后一个测试失败。 ...

20得票3回答
如何将@DataMongoTest和@SpringBootTest一起在集成测试中使用

我正在尝试编写一个集成测试用例,针对我的REST应用程序进行测试,该应用程序在内部使用MongoDB来持久化数据。@DataMongoTest @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) public class ...

13得票2回答
如何修复嵌入式Kafka找不到meta.properties文件的错误

我正在为使用kafka、kafka-streams和cassandra的应用程序尝试进行集成测试。但是当我尝试设置测试类时,出现了两个错误: ERROR [main] BrokerMetadataCheckpoint: Failed to read meta.properties file u...

8得票5回答
包 org.springframework.boot.test.context 不存在。

我使用以下依赖项 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="...

16得票1回答
Spring-boot应用程序测试.properties

我正在尝试使用junit对spring-boot应用程序进行单元测试。我已经将application-test.properties放置在src/test/resources下。我有一个ApplicationConfiguration类,它读取application.properties。 ...

12得票3回答
只有一个Bean的Spring上下文测试

有没有推荐的方法来运行Spring Boot测试,其中只有一个被测试的主题在上下文中配置。 如果我使用 @Autowired 注释来注入一个模拟服务,而不是将整个配置类添加到上下文中,会发生什么情况?@RunWith(SpringRunner.class) @SpringBootTest(p...

8得票1回答
SpringBootTest从扫描中排除包

我希望在使用spring的@SpringBootTest时,可以像使用@ComponentScan一样排除某些要扫描的包。 是否有类似的解决方法呢? @SpringBootTest(excludeFilters =@ComponentScan.Filter( type...

7得票2回答
SpringbootTest + TestContainers:测试时如何刷新数据库,以清除测试数据的影响

我正在使用一个抽象类,如下所示: @SpringBootTest(classes = MyAppApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public abs...

9得票2回答
为什么Spring Boot的DataJpaTest要扫描@Component?

Confident this hasn't been asked but reading through the Spring docs and testing utilities I found this annotation and thought I'd start using it. ...

9得票2回答
使用Spring Kafka添加自定义头部

我计划在Spring Boot应用程序中使用Spring Kafka客户端从Kafka设置中消费和生产消息。我看到Kafka 0.11支持自定义头信息,详见这里。虽然原生的Kafka生产者和消费者支持该功能,但是我没有看到Spring Kafka支持添加/读取自定义头信息。 我正在尝试基于重...