1.在pom.xml中添加依赖

2.编写待测程序

3.配置bean文件

4.编写测试程序
鼠标停在Max类的后面按“Alt+Enter”,选择“Create Test”,选择Generate->Test,在如图所以界面勾选JUnit4,并勾选待测方法

完成后,编写MaxTest类

- 使用assertEquals断言,判断期望值和实际值是否相等
- @RunWith注解:指定单元测试环境
- @ContextConfiguration:指定配置文件路径
鼠标停在Max类的后面按“Alt+Enter”,选择“Create Test”,选择Generate->Test,在如图所以界面勾选JUnit4,并勾选待测方法
完成后,编写MaxTest类
本文标题:8. 在Spring5中使用Junit
本文链接:https://www.haomeiwen.com/subject/nbdwuqtx.html
网友评论