Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JUnit 5测试未启动,测试为';t在测试转轮中显示_Java_Maven_Visual Studio Code_Junit5 - Fatal编程技术网

Java JUnit 5测试未启动,测试为';t在测试转轮中显示

Java JUnit 5测试未启动,测试为';t在测试转轮中显示,java,maven,visual-studio-code,junit5,Java,Maven,Visual Studio Code,Junit5,我很难让JUnit5测试在VSCODE上运行。我相信我的环境设置得很好。junit5示例的克隆| junit5 jupiter starter maven按预期构建和运行。我的项目没有 我的项目在maven下构建,但不运行任何测试。因此,这可能是一个Maven或项目配置问题,与VSCODE无关 我花了几个小时修改各种想法,但都没有用。有些东西是不同的,可能是一个错误,也许更多的眼睛可以找到它。如果您能提供任何帮助,我们将不胜感激 以下是一些项目信息 “mvn clean package”运行时没

我很难让JUnit5测试在VSCODE上运行。我相信我的环境设置得很好。junit5示例的克隆| junit5 jupiter starter maven按预期构建和运行。我的项目没有

我的项目在maven下构建,但不运行任何测试。因此,这可能是一个Maven或项目配置问题,与VSCODE无关

我花了几个小时修改各种想法,但都没有用。有些东西是不同的,可能是一个错误,也许更多的眼睛可以找到它。如果您能提供任何帮助,我们将不胜感激

以下是一些项目信息

“mvn clean package”运行时没有错误,但没有运行任何测试。CodeLens也不工作

缺少运行测试|调试测试。测试运行程序中未显示任何测试。

以下是我的POM文件,其中包含一些修订:

  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.redacted</groupId>
  <artifactId>redacted</artifactId>
  <packaging>jar</packaging>
  <version>0.1.1</version>
  <name>redacted</name>

  <properties>
    <skipTests>false</skipTests>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
    <junit.jupiter.version>5.6.2</junit.jupiter.version>
  </properties>

  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>${junit.jupiter.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <source>${maven.compiler.source}</source>
          <target>${maven.compiler.target}</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.2</version>
        <configuration>
          <!-- <skipTests>${skipTests}</skipTests> -->
        </configuration>
      </plugin>
      <!-- <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.22.2</version>
      </plugin> -->
      <plugin>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-codegen-plugin</artifactId>
        <version>3.3.6</version>
        <executions>
          <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
              <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
              <wsdlOptions>
                <wsdlOption>
                  <wsdl>${basedir}/WSDL/redacted.wsdl</wsdl>
                </wsdlOption>
              </wsdlOptions>
            </configuration>
            <goals>
              <goal>wsdl2java</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance“xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
编辑
编辑
罐子
0.1.1
编辑
假的
UTF-8
1.8
${maven.compiler.source}
5.6.2
http://maven.apache.org
org.junit.jupiter
朱尼特朱庇特
${junit.jupiter.version}
测试
maven编译器插件
3.8.1
${maven.compiler.source}
${maven.compiler.target}
maven surefire插件
2.22.2
org.apache.cxf
cxf-codegen插件
3.3.6
生成源
生成源
${project.build.directory}/generated/cxf
${basedir}/WSDL/redact.WSDL
wsdl2java
以下是mvn命令的输出:

[INFO] 
[INFO] ------------------------< com.redacted:redactedClient >-------------------------
[INFO] Building redactedClient 0.1.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ redactedClient ---
[INFO] Deleting D:\repos\redacted\redactedClient\target
[INFO] 
[INFO] --- cxf-codegen-plugin:3.3.6:wsdl2java (generate-sources) @ redactedClient ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ redactedClient ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\repos\redacted\redactedClient\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ redactedClient ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to D:\repos\redacted\redactedClient\target\classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ redactedClient ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\repos\redacted\redactedClient\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ redactedClient ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\repos\redacted\redactedClient\target\test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ redactedClient ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.444 s
[INFO] Finished at: 2020-04-26T09:55:55-07:00
[INFO] ------------------------------------------------------------------------
[信息]
[信息]----------------------------------------------------
[信息]正在构建redactedClient 0.1.1
[信息]------------------------------------[jar]---------------------------------
[信息]
[信息]---maven clean插件:2.5:clean(默认清洁)@redactedClient---
[信息]删除D:\repos\redacted\redactedClient\target
[信息]
[信息]---cxf codegen插件:3.3.6:wsdl2java(生成源代码)@redactedClient---
[信息]
[信息]---maven资源插件:2.6:resources(默认资源)@redactedClient---
[信息]使用“UTF-8”编码复制筛选的资源。
[信息]跳过不存在的资源目录D:\repos\redacted\redactedClient\src\main\resources
[信息]
[信息]---maven编译器插件:3.8.1:compile(默认编译)@redactedClient---
[信息]检测到更改-重新编译模块!
[INFO]正在将6个源文件编译为D:\repos\redacted\redactedClient\target\classes
[信息]
[信息]---maven资源插件:2.6:testResources(默认testResources)@redactedClient---
[信息]使用“UTF-8”编码复制筛选的资源。
[信息]跳过不存在的资源目录D:\repos\redacted\redactedClient\src\test\resources
[信息]
[信息]---maven编译器插件:3.8.1:testCompile(默认testCompile)@redactedClient---
[信息]检测到更改-重新编译模块!
[INFO]正在将1个源文件编译为D:\repos\redacted\redactedClient\target\test classes
[信息]
[信息]---maven surefire插件:2.22.2:test(默认测试)@redactedClient---
[信息]
[信息]-------------------------------------------------------
[信息]
[信息]-------------------------------------------------------
[信息]
[信息]结果:
[信息]
[信息]测试运行:0,失败:0,错误:0,跳过:0
[信息]
[信息]------------------------------------------------------------------------
[信息]建立成功
[信息]------------------------------------------------------------------------
[信息]总时间:8.444秒
[信息]完成时间:2020-04-26T09:55:55-07:00
[信息]------------------------------------------------------------------------

测试方法应具有返回类型
void
,而您的测试方法
GetModList()
具有
Boolean


在JUnit Jupiter中,您可以从测试类中删除public,也可以从所有测试方法中删除public。

您应该添加
JUnit Jupiter engine
作为依赖项,而不是
JUnit Jupiter
。Surefire 2.22.X将由此触发。在surefire 3.X junit jupier api中,我想知道为什么您的测试方法
GetModList()
会返回一些通常测试方法具有的
void
。。。您可以从测试方法中删除
public
,也可以从测试类本身中删除。我已确定目标文件夹不包含类AppTest.class文件。因此,可能没有选择AppTest.java进行编译?@khmarbaise切换到void并删除public没有乐趣。出于某种原因,Maven没有编译AppTest.java。目标文件夹中的文件名搜索没有显示对“AppTest”@khmarbaise的引用。请在建议的答案中发布关于void和public的第二条评论。快速提示:我花了一段时间来整理,因为${basedir}src/test/java中的这个POM条目也会导致相同的症状。我在发布问题和尝试@khmarbaise最初的建议之间添加了它。那里的文件夹确实存在,因此我不确定它为什么会导致问题。对源代码执行同样的操作很好${basedir}/src/main/java您应该删除
配置,因为它违反了配置范例的约定..目录覆盖不好。不幸的是,这是由于需要将JUnit添加到当前使用命令行测试的许多项目中。这些项目正在使用