|
我是个新手,刚学习了点JUINT,现练习写个测试类,但是遇到问题了,不知道错在哪里,请师傅指点一二.
JAVA原类如下:
package test;
public class YY {
public static void main(String[] args)
{
YY e = new YY();
e.printIt("One, ")
.printIt("Two, ")
.printIt("Three, ");
}
public YY printIt(String s)
{
System.out.print(s);
return this;
}
}
测试类如下"
package test;
import junit.framework.TestCase;
public class YYTest extends TestCase {
public YY y1;
public String s;
protected void setUp() throws Exception {
super.setUp();
y1=new YY();
}
protected void tearDown() throws Exception {
super.tearDown();
}
public void printItTest() throws Exception
{
assertEquals("one",y1.printIt(s));
}
public static void main(String[] args) {
junit.textui.TestRunner.run(YYTest.class);
}
}
在ECLIPSE下运行,错误提示如下:
junit.framework.AssertionFailedError: No tests found in test.YYTest
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.TestSuite$1.runTest(TestSuite.java:93)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:228)
at junit.framework.TestSuite.run(TestSuite.java:223)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
junit.framework.AssertionFailedError: No tests found in test.YYTest
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.TestSuite$1.runTest(TestSuite.java:93)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:228)
at junit.framework.TestSuite.run(TestSuite.java:223)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
这是怎么回事呀,我的测试类写的一定有问题吧,应该怎么样写呀 |
|