Java Can';我不能让Maven运行JUnit测试

Java Can';我不能让Maven运行JUnit测试,java,maven,junit,Java,Maven,Junit,我想我以前什么都试过了,但没有成功 我有一个Java项目,在src/test/Java中有一个junit jupiter测试类,名为SacmElementTest。如果我将它作为来自Eclipse的JUnit测试运行,那么测试运行得很好——其中有8个测试。但是如果我从Maven(在eclipse中或从命令行)运行测试,一切看起来都很好,但是我得到测试运行:0,失败:0,错误:0,跳过:0,因此它实际上没有运行测试。我的pom文件是: <project xmlns="http://maven

我想我以前什么都试过了,但没有成功

我有一个Java项目,在src/test/Java中有一个junit jupiter测试类,名为SacmElementTest。如果我将它作为来自Eclipse的JUnit测试运行,那么测试运行得很好——其中有8个测试。但是如果我从Maven(在eclipse中或从命令行)运行测试,一切看起来都很好,但是我得到
测试运行:0,失败:0,错误:0,跳过:0,因此它实际上没有运行测试。我的pom文件是:

<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>uk.co.tgrsafety</groupId>
<artifactId>gsn-editor-maven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>gsn-editor</name>
<build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
        <resource>
            <directory>src</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>

    <testSourceDirectory>src/test/java</testSourceDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <release>10</release>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>1.10.19</version>
    </dependency>
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-surefire-provider</artifactId>
        <version>1.2.0-M1</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.2.0-M1</version>
    </dependency>
</dependencies>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
</project>

4.0.0
uk.co.tgrsafety
gsn编辑maven
0.0.1-快照
gsn编辑器
src
src
**/*.爪哇
src/test/java
maven编译器插件
3.7.0
10
org.mockito
莫基托磁芯
1.10.19
org.junit.platform
junit平台surefire提供程序
1.2.0-M1
org.junit.jupiter
朱尼特木星发动机
5.2.0-M1
UTF-8
UTF-8

我做错了什么?

请添加具有正确依赖关系的maven surefire插件,如下所述


maven surefire插件
2.21.0
org.junit.platform
junit平台surefire提供程序
1.2.0
org.junit.jupiter
朱尼特木星发动机
5.2.0

请添加具有正确依赖关系的maven surefire插件,如下所述


maven surefire插件
2.21.0
org.junit.platform
junit平台surefire提供程序
1.2.0
org.junit.jupiter
朱尼特木星发动机
5.2.0

Surefire插件的2.22.0版支持内置JUnit Jupiter。根据its,您必须将JUnit Jupiter引擎添加到项目依赖项中

<project ...>
  ...
  <dependencies>
    ...
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>5.2.0</version>
      <scope>test</scope>
    </dependency>
    ...
  </dependencies>
  ...
  <build>
    <plugins>
      ...
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.0</version>
      </plugin>
      ...
    </plugins>
  </build>
</project>

...
...
org.junit.jupiter
朱尼特木星发动机
5.2.0
测试
...
...
...
maven surefire插件
2.22.0
...

Surefire插件的2.22.0版支持内置JUnit Jupiter。根据its,您必须将JUnit Jupiter引擎添加到项目依赖项中

<project ...>
  ...
  <dependencies>
    ...
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>5.2.0</version>
      <scope>test</scope>
    </dependency>
    ...
  </dependencies>
  ...
  <build>
    <plugins>
      ...
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.0</version>
      </plugin>
      ...
    </plugins>
  </build>
</project>

...
...
org.junit.jupiter
朱尼特木星发动机
5.2.0
测试
...
...
...
maven surefire插件
2.22.0
...

请同时从project explorer发布您的项目目录结构。共享您的源文件夹结构。maven默认情况下遵循
src/test/**
如果条目存在classpath,请同时从project explorer发布项目目录结构。共享源文件夹结构。maven在默认情况下遵循
src/test/**
如果条目存在,则存在类路径