首页 > 技术文章 > 折腾一上午, 终于解决了assertThat()无法运行的错误

mayingdts 2020-09-14 22:45 原文

问题描述:

1. assertThat()红色报警

2. is()红色报警

  

问题解决:

1. 导入  import static org.hamcrest.MatcherAssert.assertThat;  

 注意: 不要导入org.junit.Assert.assertThat, 因为这个包里的assertThat()已经Deprecated, 需要use org.hamcrest.MatcherAssert.assertThat() 

2. 导入   import static org.hamcrest.CoreMatchers.is;

 或者    import static org.hamcrest.core.Is.is;  

导入过程:

1.------------------------------------------------------------------------

2.---------------------------------------------------------------------------------

 

 

推荐阅读