Junit中Assert断言的使用

今天看到测试用例规范中说,不能用System.out.println()校验,要用assert断言。

百度用法, 终于找到了这篇文章,很详细。

因为很多人写的都是assert(boolean) 然后再System.out.println(),-->(这种导入的包是:import org.springframework.util.Assert;)

我就疑问,这不还是用了system.out嘛

然后assertNotNull()之类的方法用不了,原来是包引入错了!!!!

导包为静态导入:import static org.junit.Assert.*; import static org.hamcrest.CoreMatchers.*;

可以用这些方法 assertNotNull

转载:https://blog.csdn.net/qq_36688143/article/details/86305807

你可能感兴趣的:(学习总结,工具,技术)