Using Spock to mock private static final variables in Java

后端 未结 2 457
感情败类
感情败类 2020-12-16 19:21

I\'m trying to write some Spock tests with Groovy to test some Java code (specifically a servlet Filter). I have some private static and private static fi

2条回答
  •  甜味超标
    2020-12-16 20:23

    Either you need to use PowerMock (or another similar solution), or refactor your code. Spock does not support mocking of private/static/final methods on its own. This limitation is also present in Mockito, so that must give you a hint on best-practices.

提交回复
热议问题