小编Cra*_*son的帖子

PowerMock测试 - 设置类的静态字段

我很难找到设置类的静态字段的方法.它基本上是这样的:

public class Foo{
    // ...
    private static B b = null;
}
Run Code Online (Sandbox Code Playgroud)

其中B是另一个类.

有什么方法可以在PowerMock中执行此操作而不是使用setInternalStateFromContext()?使用上下文类方法对于设置一个字段似乎有点过分.

谢谢.

junit static mocking powermock

41
推荐指数
3
解决办法
6万
查看次数

标签 统计

junit ×1

mocking ×1

powermock ×1

static ×1