MockStatic of Unit Test
来源:互联网 发布:平衡面板数据是什么 编辑:程序博客网 时间:2024/05/20 08:01
-- Configure class:
1. Use the @RunWith(PowerMockRunner.class) annotation at the class-level of the test case.2. Use the @PrepareForTest(ClassThatContainsStaticMethod.class) 3. annotation at the class-level of the test case.
3. Use PowerMock.mockStatic(ClassThatContainsStaticMethod.class) to mock all methods of this class.
4. Use PowerMock.replay(ClassThatContainsStaticMethod.class) to change the class to replay mode.
5. Use PowerMock.verify(ClassThatContainsStaticMethod.class) to change the class to verify mode.
-- Learned:
1. mockStatic(*.class) is to mock all the static methods (even with final) of the class.2. when(#1).then(#2),#1 is a static method called by a class, and the static method is mocked by -1-.
-- Question:
1. How the PowerMock.replay work and what's the effect?2. How the PowerMock.verify work and what's the effect?
阅读全文
0 0
- MockStatic of Unit Test
- Art of Unit Test :: Stubs
- Unit test, lack of the dlls
- unit test
- Unit Test
- Unit test
- UNIT TEST
- Unit Test
- Unit Test
- Unit Test、 UI Test
- unit Test 筆記-write unit test
- [转]Unit Test 原则
- Unit Test研究报告
- vs2005 unit test 点滴
- Design to Unit Test
- Unit Test Frameworks
- j2me unit test
- Unit Test Key Points
- Cocos2d-x 之帧动画 Animate
- 使用rsync +cwrsync实现windows和linux的文件同步
- 服务器运维学习中的知识点积累
- Git使用中出现的错误以及解决办法积累
- kobj_attribute
- MockStatic of Unit Test
- 搭建Springmvc+Mybatis+Spring环境
- 使用gradle打war包时,包含中文文件名导致war包无法解压的解决办法
- Linux CentOS中Java环境变量的配置
- SpringBoot设置Filter过滤请求参数
- 使用Idea打开Maven项目的正确姿势
- Java菜鸟面试突破系列之事物方方面面(事物种类特性及隔离级别、悲观锁和乐观锁等)
- 韩大帅的工作中出现的报错集(更新中)
- 从零开始的 Win7 64Bit 编译Hadoop3