今天再写Junit单元测试的时候,用到assertThat方法,但是eclipse死活都不能识别这个方法,起初以为Jar冲突导致,结果发现不是,原来是eclipse的问题(不知道其他的版本是否还有这个问题,我的是3.7),不能够自动导入hamcrest的方法,因此如果想使用assertThat方法,我们需要手动的添加如下的两行代码:

1 import static org.junit.Assert.*;
2 import static org.hamcrest.CoreMatchers.*;

这样子就可以正常工作了。

 

关于最新的assertThat用法,可以参考淘宝测试组的Blog:Junit4 新断言语法介绍

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-04
  • 2022-12-23
  • 2022-01-20
  • 2021-09-28
  • 2021-08-27
  • 2021-12-21
猜你喜欢
  • 2022-02-27
  • 2021-12-21
  • 2021-04-29
  • 2021-05-16
  • 2021-05-04
  • 2021-08-26
  • 2021-08-05
相关资源
相似解决方案