我的 build.gradle
文件中有以下依赖项
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'
我的测试类 EmailValidatorTest
有以下代码
@Test
public void emailValidator_simpleEmail_returnsTrue(){
assertThat(EmailValidator.isValidEmail("name@ex.com"),is(true))
}
但我得到的错误是 Cannot resolve symbol assertThat
。我只得到 assert
对象。我目前正在处理来自 Android Developers
的示例,即:https://github.com/googlesamples/android-测试/树/master/unit/BasicSample
.
最佳答案
确保您导入了 assertThat .
public static <T> void assertThat(T actual,
org.hamcrest.Matcher<T> matcher)
import static org.hamcrest.MatcherAssert.assertThat;
然后清理-重建-运行。
关于android - 无法解析符号 assertThat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45586828/