ITeye博客

UT

共 2 篇文章

mock System class with powermock

Use the @RunWith(PowerMockRunner.class) annotation at the class-level of the test case. Use the @PrepareForTest({ClassThatCallsTheSystemClass.class}) annotation at the class-level of the test case. Use mockStatic(SystemClass.class) to mock the system class then setup the expectations as normally. E…

2013-12-02 14:13 · java language · UT

EasyMock, PowerMock 一起mock静态方法 static method

在哪下载包就不说了,要下这么几个: easymock-3.1 easymockclassextension-3.1 powermock-easymock-junit-1.5 创建一个待会儿被mock的类, Job package com.jwu.mock; import java.util.Random; public class Job { public Job(String name) { this.name = name; } private String name; public String getName() { return name; } public static int …

2012-12-10 22:41 · java language · UT