Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/347.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已禁用是否被忽略?_Java_Intellij Idea_Junit5_Junit Jupiter - Fatal编程技术网

Java JUnit 5已禁用是否被忽略?

Java JUnit 5已禁用是否被忽略?,java,intellij-idea,junit5,junit-jupiter,Java,Intellij Idea,Junit5,Junit Jupiter,我正在使用JUnit5和IntelliJ IDEA社区版2018 我的代码很简单: import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; class CalculatorTest { @Disabled

我正在使用JUnit5和IntelliJ IDEA社区版2018

我的代码很简单:

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

class CalculatorTest {

    @Disabled
    @Test
    void addTwoZeroNumerators(){
    int[] resultExpected = {0,0};
    assertArrayEquals(resultExpected, Calculator.calculate(0,0,0,1));
}
我使用
@禁用
。但是当我运行测试时,事件日志仍然报告1测试通过。有人能告诉我这有什么问题吗?我希望系统忽略此测试

以下是日志部分的标题:


@Nicolai的答案是100%正确的,如果您强制IntelliJ执行测试,IntelliJ将执行测试


但是,如果要在生成管理系统中启用
@禁用的
注释,请记住关于surefire插件()。如果缺少,则注释将无法工作。

我认为这可能是Maven SureFire插件的一个错误,如果您有一个带有单个
@Test
@已禁用的类,它仍会尝试运行它。我已经在maven surefire插件上试用过:2.22.0、2.22.2和3.0.0-M3,所有这些插件似乎都有问题

ApacheMaven团队开出的罚单:

喷气式飞机的门票:

托尼·法拉贝拉

在Jira中,我给了你一个暗示。请使用最新的快照版本3.0.0-snapshot,并告知此问题。此快照版本可以在Apache Nexus存储库中找到。请在插件开发过程中尽快向我们提供反馈,并尝试使用快照版本,因为这样可以避免出现新问题:

<pluginRepository>
  <id>surefire-snapshot</id>
  <name>surefire-snapshot</name>
  <url>https://repository.apache.org/content/repositories/snapshots/</url>
  <snapshots>
    <enabled>true</enabled>
  </snapshots>
 </pluginRepository>
...
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>3.0.0-SNAPSHOT</version>
    </plugin>
  </plugins>
</build>

surefire快照
surefire快照
https://repository.apache.org/content/repositories/snapshots/
真的
...
org.apache.maven.plugins
maven surefire插件
3.0.0-SNAPSHOT
在吉拉我发现你用

<artifactId>junit-platform-launcher</artifactId>
junit平台启动器

请不要使用它。这与你无关。它仅与Surefire/Failsafe和IDE的使用有关。

您能显示的输出结果吗junit@afaq我已经编辑并将事件日志的屏幕标题附加到我的帖子中。我总是要确保。。。。你做了改变了吗?我不明白。你能澄清一下你的意思吗?我是个新手^^“@shinjw当告诉IntelliJ执行单个测试时,它将始终执行它-无论它是否被禁用。如果执行整个类,则不应运行禁用的测试,但可能您发现了测试类仅包含单个测试方法的错误。尝试添加第二个方法并单独执行它们以及类。如果这是一个bug,报告它。OP已经尝试过这种方法,但似乎不起作用。见他的评论。我正在使用
org.apache.maven.plugins:maven surefire plugin:2.22.0
和IntelliJ IDEA 2019.2.2(终极版)Build#IU-192.6603.28,它是在2019年9月6日构建的,
@Disabled
不适用于具有单一
@Test
方法的类,该方法也具有该方法
@Disabled