在这里使用 JUnit 4.10 是我的测试。
package geometry;
import org.junit.Assert.*;
import org.junit.Test;
public class SegmentTest extends junit.framework.TestCase {
@Test
public void SegmentParallelTest() {
Segment a = new Segment(10, 5, 20, 11);
Segment b = new Segment(20, 6, 30, 11);
assertFalse(a.isParallel(b));
}
public static junit.framework.Test suite() {
return new junit.framework.JUnit4TestAdapter(SegmentTest.class);
}
public static void main(String args[]) {
org.junit.runner.JUnitCore.main("geometry.SegmentTest");
}
}
这会产生以下错误消息...
junit.framework.AssertionFailedError: No tests found in geometry.SegmentTest
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
这种方法有什么问题?