我的项目中有以下方法
public void execute(final int apiId, final ResponseHandler handler, final Type type)
Run Code Online (Sandbox Code Playgroud)
并使用TypeToken确定类型,如下所示
final Type serviceErrorType = new TypeToken<>() {
}.getType();
Run Code Online (Sandbox Code Playgroud)
我在这里浏览了这个链接,但完全无法理解Type和TypeToken
任何人都可以分享链接或帮助理解这两个概念吗?
我的build.gradle文件中有以下依赖项
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'
Run Code Online (Sandbox Code Playgroud)
我的测试类EmailValidatorTest有以下代码
@Test
public void emailValidator_simpleEmail_returnsTrue(){
assertThat(EmailValidator.isValidEmail("name@ex.com"),is(true))
}
Run Code Online (Sandbox Code Playgroud)
但我得到的错误是Cannot resolve symbol assertThat. 我只得到assert对象。我目前正在处理来自Android Developersi,e的样本:https://github.com/googlesamples/android-testing/tree/master/unit/BasicSample。