相关疑难解决方法(0)

Maven没有运行JUnit 5测试

我试图用maven运行一个简单的junit测试,但它没有检测到任何测试.我哪里错了?项目目录

Project -> src -> test-> java -> MyTest.java
Run Code Online (Sandbox Code Playgroud)

结果:

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
Run Code Online (Sandbox Code Playgroud)

的pom.xml

<?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.buildproftest.ecs</groupId>
    <artifactId>buildprofiletest</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.3.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <debug>false</debug>
                    <optimize>true</optimize>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
Run Code Online (Sandbox Code Playgroud)

Junit测试用例

import org.junit.jupiter.api.Test;

public class MyTest {
    @Test
    public void printTest() {
        System.out.println("Running JUNIT …
Run Code Online (Sandbox Code Playgroud)

junit maven maven-surefire-plugin junit5

6
推荐指数
3
解决办法
2879
查看次数

由于maven-surefire-plugin,Maven构建失败

我有类似的问题,在这里even缺少maven-surefire-plugin

但我做了那个问题的答案,但我的构建仍然失败并出现同样的错误.

MCVE这里:https://github.com/yami12376/AspectJ

当我建立我得到:

[WARNING] Error injecting: org.apache.maven.plugin.surefire.SurefirePlugin
java.lang.TypeNotPresentException: Type org.apache.maven.plugin.surefire.SurefirePlugin not present
        at 

    ...
org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
        ... 57 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.216 s
[INFO] Finished at: 2017-04-06T18:12:01+02:00
[INFO] Final Memory: 13M/244M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project NumberGenerator: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: Unable to load the mojo 'test' in the plugin 'org.apache.maven.plugins:maven-surefire-plugin:2.12.4'. A required class is missing: org/apache/maven/plugin/surefire/SurefireReportParameters
[ERROR] ----------------------------------------------------- …
Run Code Online (Sandbox Code Playgroud)

java eclipse java-ee maven

5
推荐指数
1
解决办法
8174
查看次数

标签 统计

maven ×2

eclipse ×1

java ×1

java-ee ×1

junit ×1

junit5 ×1

maven-surefire-plugin ×1