Mocking a Spy method with Mockito

前端 未结 3 1750
时光说笑
时光说笑 2021-02-07 21:54

I am writing a unit test for a FizzConfigurator class that looks like:

public class FizzConfigurator {
    public void doFoo(String msg) {
        d         


        
3条回答
  •  自闭症患者
    2021-02-07 22:31

    This is a clear sign that doWidget method should belong to another class which FizzConfigurator would depend on.

    In your test, this new dependency would be a mock, and you could easily verify if its method was called with verify.

提交回复
热议问题