仅当按下重新运行失败的测试时,才发现 gradle 和 intellij 没有测试

时间:2021-02-05 17:27:56

标签: java spring-boot gradle intellij-idea junit

当我运行测试但测试失败并按下按钮 Rerun failed tests 时,我收到以下错误 Test events where not received No tests found for given includes,但很奇怪,因为测试刚刚运行并失败,并且当我尝试使用按钮重新运行它时重新运行测试不起作用。

我正在使用 gradle 6.8.1 intellij idea community edition 2020.3.2spring boot 2.4.2

这是我的build.gradle

plugins {
    id 'org.springframework.boot' version '2.4.2'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.mapstruct:mapstruct:1.4.2.Final'
    annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

test {
    useJUnitPlatform()
}

这是我的测试

package com.example.map.struc.example;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import static org.junit.jupiter.api.Assertions.assertTrue;

@SpringBootTest
class MapStrucExampleApplicationTests {

    @Test
    void contextLoads() {
    }

    @Test
    void name() {
        assertTrue(false);
    }
}

1 个答案:

答案 0 :(得分:0)

当使用 Gradle 运行测试时,Rerun Failed Tests 操作是一个已知问题:IDEA-194699

相关问题