未找到类:IntelliJ 中的空测试套件

2024-03-11

我刚刚在大学开始计算机科学课程,并且在使用 IntelliJ 时遇到了一些问题。当我尝试运行单元测试时,我收到消息

Process finished with exit code 1
Class not found: "edu.macalester.comp124.hw0.AreaTest"Empty test suite.

我还在屏幕左侧看到一条标题为“未找到测试”的消息。我的测试代码在这里:

package edu.macalester.comp124.hw0;


import org.junit.Test;
import static org.junit.Assert.*;

public class AreaTest {

    @Test
    public void testSquare() {
    assertEquals(Area.getSquareArea(3.0), 9.0, 0.001);
    }

    @Test
    public void testCircle() {
    assertEquals(Area.getCircleArea(3.0), 28.2743, 0.001);
    }
}

我的项目代码在这里:

package edu.macalester.comp124.hw0;

import java.lang.Math;
public class Area {

/**
 * Calculates the area of a square.
 * @param sideLength The length of the side of a square
 * @return The area
 */
public static double getSquareArea(double sideLength) {
    // Has been replaced by correct formula
    return sideLength * sideLength;
}

/**
 * Calculates the area of a circle.
 * @param radius The radius of the circle
 * @return The area
 */
public static double getCircleArea(double radius) {
    // Replaced by correct value
    return radius * 2 * Math.PI;
}

}

我怎样才能让我的测试发挥作用?我正在使用最新版本的 IntelliJ IDEA CE。


有同样的消息。我必须删除运行/调试配置。

就我而言,我之前将单元测试作为本地测试运行。之后,我将测试移至 androidTest 包并尝试再次运行它。 Android Studio 记住了上次运行配置,因此它尝试将其作为本地单元测试再次运行,但产生了相同的错误。

删除配置并再次运行测试后,它生成了新配置并起作用。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

未找到类:IntelliJ 中的空测试套件 的相关文章

随机推荐