java - Spring Boot 无法在 IntelliJ 中运行单个测试

标签 java spring intellij-idea spring-boot kotlin

最近开始发生这种情况,但我不确定是什么变化导致了它。

  • 当我从 IntelliJ 运行所有测试时,一切都很好。 gradle构建也很好。
  • 当我运行一个单元测试时,一切都很好。
  • 当我运行单个 Web 集成测试时,它失败了,因为配置类具有所有空属性。

配置类看起来像(Kotlin):

@Component
@ConfigurationProperties(prefix = "api")
public open class ApiConfigImpl : ApiConfig
{ 

一个测试看起来像:

@RunWith(SpringJUnit4ClassRunner::class)
@ContextConfiguration(classes = arrayOf(ApplicationAssembly::class), loader = SpringApplicationContextLoader::class)
@WebIntegrationTest
open class CandidateProfileControllerTest
{

    @Inject lateinit var profileRepo: CandidateProfileRepository
    //etc a few more deps used to setup test data

    @Test
    open fun getById()
    {
        val greg = CandidateProfile("123", "12312", "Greg", "Jones",   dateOfBirth = Date(), gender = Gender.MALE,
            biography = "ABC", maxMatchableAge = null,   maxMatchableDistance = null)
        profileRepo.save(greg)

        val auth = given().header("content-type", "application/json")
            .body(testCredentials)
            .post("/authorization/social").peek().asString()
        val accessToken: String = from(auth).get("accessToken")

        given().header("Access-Token", accessToken).
            header("API-Key", testAPIKey()).
            get("/profile/${greg.id}").
            peek().then().
            body("stageName", notNullValue())
    }

我不确定我可以添加哪些信息。根据提供的有限信息:

  • 这是已知解决方案的已知问题吗?

最佳答案

这是一个错误,登录 IntelliJ/Kotlin tracker ,有待修复。

关于java - Spring Boot 无法在 IntelliJ 中运行单个测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35177535/

相关文章:

java - 在 Spring Integration 中使用拦截器发送日志消息

java - spring security中尝试访问登录页面时访问被拒绝异常

java - 在 spring 中加载属性文件时出现问题

java - 正则表达式用于在java中匹配和删除字符串中的数字

java - Log4j 在基类中创建日志实例

java - Tomcat 配置文件 ../context.xml 似乎已损坏。请确保它是可解析的和有效的。有关详细信息,请参阅服务器日志

java - Mockito 中的 Spring @Value 字段注入(inject)

java - 断点/框架在 IntelliJ 中不起作用

java - 如何在不重新排列导入语句的情况下动态优化导入?

java - 为什么我在创建新的 Android 项目时遇到渲染错误?