Intellij IDE未运行单元测试

时间:2019-06-04 14:54:30

标签: intellij-idea

我正在运行IntelliJ IDEA 2018.3.1,并尝试使用集成的测试运行器测试课程。该测试似乎可以编译但无法运行。

这是一个多模块Maven项目,其他模块具有运行的测试。但是,我无法在项目之间找到任何差异。 surefire插件专门在此项目上定义,<skipTests>专门设置为false。我已经多次导入了该项目,以防maven配置影响内置的运行器。

下面的图像是我得到的唯一输出。调试/断点不会停止。

enter image description here

如果有人能帮助我或给我带来可能性,我将不胜感激。

编辑:

这是我尝试运行的测试的简化版本:

package com.jason;

// imports

@RunWith(BlockJUnit4TestRunner.class)
public class MyTest {

    private ClassUnderTest clazz;

    private DaoClass dao;

    @Before
    public void setUp() {
       // using Mockito to mock the DaoClass

       // injecting the DAO into the ClassUnderTest
    }

    @Test
    public void testMethod() {

        Assert.assertTrue(true);
    }
}

我尝试通过右键单击带有@Test的方法并单击运行来运行测试。运行测试DOES的选项出现在上下文菜单中。当我这样做时,所有显示的就是屏幕截图。

我尝试执行以下操作以解决该问题:

    • 在相应模块的pom.xml文件中,我在<build><plugins>部分中手动指定了surefire插件。然后,我重新导入以获取更改。
  • 我已经在代码中放置了断点,并以调试模式运行测试。
  • 我尝试使用slf4j记录器和System.out.println()记录输出
  • 我试图在运行测试的模块与未运行测试的模块之间的IDEA .iml文件中发现任何差异。
  • 我编写了一个非常简单的测试类,其方法用@Test注释并且包含行Assert.assertTrue(true)

编辑2  尝试运行mvn test -Dcontrollername会产生以下输出:

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project rma-svc: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?

编辑3

我已经将Maven surefire插件更新为2.22.2,并且不再看到派生的JVM问题。但是,运行mvn test -DskipTests=false会输出No tests were executed!

0 个答案:

没有答案