[英]Can't find assertThat
這是我的代碼
import org.junit.Test;
import static org.junit.Assert.assertThat;
import static sun.nio.cs.Surrogate.is;
public class PlayerTest {
public void should_return_3_when_status_is_3(){
Player player = new Player();
assertThat(player.getStatus(),is(3));
}
}
這是追蹤
Can't find symbol
符號: method assertThat(int,boolean)
位置: class PlayerTest
我的iml文件是
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" scope="TEST">
<library>
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.10.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
我想以前用過它,但現在不行。 不知道該怎么做。但是assertTrue正在工作。 正在使用Ubuntu 11.04。
錯誤在於
import static sun.nio.cs.Surrogate.is;
is()
應該返回一個匹配器,但無論如何,它都返回boolean。 請嘗試使用org.hamcrest.Matchers.is
或org.hamcrest.CoreMatchers.is
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.