交付进度紧张,为什么还要花费精力写单元测试代码,如下是之前的笔记。
工欲善其事,必先利其器。使用Java语言交付项目时,需要掌握单元测试框架和Mock工具的使用。
如下是当年交付项目过程中,使用过的测试框架和工具,可供参考。
测试用例的开发框架,从JUnit3一直到JUnit4。
JUnit5发布后,岗位的变化,在项目里写代码的机会不多,因此没有太多使用经验。
A programmer-oriented testing framework for Java.
The 5th major version of the programmer-friendly testing framework for Java and the JVM.
使用JUnit5时,修改项目的pom.xml
,增加如下配置:
org.junit.jupiter
junit-jupiter-api
5.10.3
test
org.junit.jupiter
junit-jupiter-engine
5.10.3
test
org.junit.jupiter
junit-jupiter
5.10.3
test
使用JUnit4时,修改项目的pom.xml
,增加如下配置:
junit
junit
4.13.2
test
当年作为骨干参与祖传项目的交付,使用EasyMock配合PowerMock,写了很多单元测试,对于稳固产品质量,改善生活质量,非常有帮助。
EasyMock, makes mocking easier since 2001.
EasyMock is a Java library that provides an easy way to use Mock Objects in unit testing.
修改项目的pom.xml
,增加如下配置:
org.easymock
easymock
5.4.0
test
对于老项目来说,静态类满天飞,PowerMock非常有用。
当年作为骨干参与祖传项目的交付,使用EasyMock配合PowerMock,写了很多单元测试,对于稳固产品质量,改善生活质量,非常有帮助。
检查提交记录,发现最近的提交已在2022年2月24日。
除非有新的开发者加入,否则本项目短期内不会有新的进展。
PowerMock is a Java framework that allows you to unit test code normally regarded as untestable.
I don't personally have time to maintain PowerMock anymore, and from what I understand from @thekingn0thing, the same is true for him. Is anyone else willing to move it forward? I'd be happy to give access etc if anyone is willing to do so.
依据帖子中作者@johanhaleby的上述答复,短期内可能不会重启项目的开发工作。
修改项目的pom.xml
,增加如下配置:
org.powermock
powermock-module-junit4
2.0.9
test
org.powermock
powermock-core
2.0.9
test
刚入行的时候,隔壁项目组大规模应用本工具交付单元测试和集成测试代码,当时作为新手,除了哇塞,也不知道说啥好。
修改项目的pom.xml
,增加如下配置:
org.jmockit
jmockit
1.49
test
曾经在一个项目中使用过,不过这个项目的生命周期比较短,所以积累不多。
Most popular Mocking framework for unit tests written in Java.
修改项目的pom.xml
,增加如下配置:
org.mockito
mockito-core
5.12.0
test
org.mockito
mockito-junit-jupiter
5.12.0
test
场景化测试、数据驱动测试,之前参与网络控制器的业务时,广泛使用了本工具来开发单元测试和集成测试代码,非常方便。
Cucumber is a tool for running automated acceptance tests, written in plain language.
Cucumber for the JVM.
修改项目的pom.xml
,增加如下配置:
io.cucumber
cucumber-java
7.18.1
io.cucumber
cucumber-junit
7.18.1
test
io.cucumber
cucumber-core
7.18.1
本文来自博客园,作者:jackieathome,转载请注明原文链接:https://www.cnblogs.com/jackieathome/p/18352288
参与评论
手机查看
返回顶部