简体   繁体   English

IntelliJ Idea - JUnit5 - 出现错误 -> ['@Suite' 不适用于方法]

[英]IntelliJ Idea - JUnit5 - Getting an error -> [ '@Suite' not applicable to method ]

I was setting up JUnit5 in IntelliJ IDEA but while defining @Suite annotation, I am getting an error like - > [ '@Suite' not applicable to method ].我在 IntelliJ IDEA 中设置了 JUnit5,但是在定义 @Suite 注释时,我收到了一个错误,例如 - > ['@Suite' not applicable to method]。 Tried to search solution on google but couldn't get similar one.试图在谷歌上搜索解决方案,但找不到类似的解决方案。 Could someone please help.有人可以帮忙吗。

Maven POM file Maven POM 文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.unitTest</groupId>
    <artifactId>JUnit5</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <java.version>8</java.version>
        <maven.compiler.version>1.8</maven.compiler.version>
        <maven.target.version>1.8</maven.target.version>
        <maven.surefire.version>3.0.0-M5</maven.surefire.version>
        <junit.jupiter.version>5.0.0-M2</junit.jupiter.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite-api</artifactId>
            <version>1.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite-engine</artifactId>
            <version>1.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <version>5.7.0</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit</groupId>
            <artifactId>junit-bom</artifactId>
            <version>5.7.0</version>
            <type>pom</type>
            <scope>test</scope>
        </dependency>
    </dependencies>


</project>

Error Screen错误屏幕

在此处输入图像描述

SuiteTYPE为目标,这意味着它只能应用于类、接口(包括注释类型)或 Enum 声明,而不能应用于方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM