Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
List<String> list = mock(List<String>.class);
这是一个无效的语法,如何将List<String>类型传递给 mock()?
List<String>
简短的回答是你不能。在运行时,这只是List.class由于类型擦除。如果您的模拟框架需要知道类型参数,则必须有不同的方式来传递它。
List.class