我刚刚在我的大学开始计算机科学计划,而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的最新版本。
mvn clean package
在终端上键入一样简单。不确定IntelliJ为什么一开始就错误地导入了项目。