相关疑难解决方法(0)

用于集成测试的Spring-boot默认配置文件

Spring-boot使用Spring配置文件(http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html),它允许例如为不同的环境分别配置.我使用此功能的一种方法是配置测试数据库以供集成测试使用.我想知道是否有必要创建我自己的配置文件'test'并在每个测试文件中明确激活此配置文件?现在我用以下方式做到:

  1. 在src/main/resources中创建application-test.properties
  2. 在那里编写测试特定的配置(现在只是数据库名称)
  3. 在每个测试文件中包括:

    @ActiveProfiles("test")
    
    Run Code Online (Sandbox Code Playgroud)

有更聪明/更简洁的方式吗?例如,默认测试配置文件?

编辑1:这个问题与Spring-Boot 1.4.1有关

java spring spring-boot

64
推荐指数
9
解决办法
7万
查看次数

错误“带有 ID 'junit-vintage' 的 TestEngine 未能发现测试”与 Spring Boot 2.2

我有一个使用 Spring Boot 和 Junit 5 的简单应用程序:

  • 使用 Spring Boot 2.1(例如 2.1.8 或 2.1.12)时,我的单元测试运行顺利

  • 使用 Spring Boot 2.2(例如 2.2.2.RELEASE 或 2.3.2.RELEASE)时,我的单元测试失败并显示错误消息

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project XXX: There are test failures.
[ERROR]
[ERROR] Please refer to D:\Projets\workspace\XXX\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] There was an error in the forked process
[ERROR] TestEngine with ID 'junit-vintage' failed to discover tests
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There …
Run Code Online (Sandbox Code Playgroud)

spring-boot junit5

60
推荐指数
8
解决办法
7万
查看次数

标签 统计

spring-boot ×2

java ×1

junit5 ×1

spring ×1