我刚刚在我的大学开始计算机科学课程,而且我在使用IntelliJ时遇到了一些问题.当我尝试运行单元测试时,我收到了消息
Process finished with exit code 1
Class not found: "edu.macalester.comp124.hw0.AreaTest"Empty test suite.
Run Code Online (Sandbox Code Playgroud)
我还在屏幕左侧看到一条标题为"未找到测试"的消息.我的测试代码在这里:
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);
}
}
Run Code Online (Sandbox Code Playgroud)
我的项目代码在这里:
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 …Run Code Online (Sandbox Code Playgroud) 我正在试图找出IntelliJ/Android报告"空测试套件"的原因.我有一个带有两个IntelliJ模块的小项目(Eclipse中的"Projects").Unit测试模块有自己的AndroidManifest.xml,我在底部粘贴了它.我试图运行ActivityUnitTestCase,因为测试将取决于对象Context.
主模块的包名称是nilzor.myapp.测试模块的pacakge名称是nilzor.myapp.tests
为什么测试运行器没有检测到testBlah()-method作为测试?
<?xml version="1.0" encoding="utf-8"?>
<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nilzor.myapp.tests"
android:versionCode="1"
android:versionName="1.0">
<!-- We add an application tag here just so that we can indicate that
this package needs to link against the android.test library,
which is needed when building test cases. -->
<application>
<uses-library android:name="android.test.runner"/>
</application>
<!--
This declares that this application uses the …Run Code Online (Sandbox Code Playgroud)