我是JUnit的新手,用的是inteliji idea。
import org.junit.Test;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.Date;
import static org.junit.Assert.*;
public class TestQuote {
@Test
public void testQuote() {
Date date = new Date(System.currentTimeMillis());
Quote quote=new Quote("a",date,200.0,300.0,100.0,107.0,1.0);
assertNull("Object is null",quote);
assertEquals("Symbol is ok",quote.getSymbol(),"a");
assertEquals("Date is ok",quote.getDate(),System.currentTimeMillis());
assertEquals("Open price is ok",quote.getOpenPrice(),200.0);
assertEquals("High price is ok",quote.getHighPrice(),300.0);
assertEquals("Low price is ok",quote.getLowPrice(),100.0);
assertEquals("Close price is ok",quote.getClosePrice(),107.0);
}
}下面是我的测试类的代码。JUnit.jar被添加到类路径中,但当我运行它时,它显示:
java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing有什么解决办法吗?顺便说一句,主程序运行正常。
发布于 2013-05-18 22:41:53
请访问JUnit网站:http://junit.org/
然后点击“下载和安装指南”:https://github.com/junit-team/junit/wiki/Download-and-Install
然后阅读:
下载以下JAR并将它们放到您的测试类路径中:
https://stackoverflow.com/questions/16625356
复制相似问题