JUnit 5测试未触发且测试运行程序中未显示测试

BigTFromAZ:

我无法让JUnit 5测试在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>

这是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] ------------------------------------------------------------------------
khmarbaise:

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

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法运行测试类“未找到测试运行程序‘Junit5’的测试”

Junit STS - 未发现测试运行程序“Junit 5”的测试

使用JUNIT测试运行AsyncHttpClient

在Eclipse中找不到以junit测试运行

如何在Eclipse中使用运行方式> SWTBot测试运行JUnit 5测试

未通过测试运行器JUnit5找到测试

带有Spring Boot JUnit 5测试的Wiremock:测试运行后正在使用的地址

是否可以从Java内部启动JUnit 5测试类的测试运行?

android JUnit测试未运行

如何按顺序制作junit测试运行方法

创建Junit测试用例后,“以Junit测试运行”消失

使用 Micronaut 应用程序在 JUnit5 中为每个单元/集成测试运行一次 TestContainer

如何终止已进入无限循环的Eclipse中的JUnit测试运行

如何使用jUnit测试运行器在Intellj中创建新的Leiningen Clojure项目?

JUnit测试中未为带注释的字段触发验证,但在正常运行应用程序时触发了验证

尝试运行琐碎的Android JUnit测试。得到:“测试运行失败:没有测试结果”我缺少什么?

我可以在测试运行时跳过JUnit测试吗?

为android gradle junit测试运行获取XML / HTML测试结果

在Junit测试案例中,@ Before函数未触发

Maven 2未运行Junit 4测试

Jenkins Maven构建未运行JUnit测试

JUnit 5测试用例未执行

业力测试运行程序未运行任何测试

有没有办法在完整的测试运行期间记录JUnit5 @Disabled原因值?

JUnit测试未捕获异常

JUnit本地测试-'未解决的参考:测试'

Junit4在测试运行时引发异常

当我“将Spring作为JUnit测试运行”时,内部会发生什么?

如何将参数从 Gradle 插件传递到 JUnit4 测试运行器?