mockito測試框架

1. code

package com.springinaction.knights;
import static org.mockito.Mockito.*;

import org.junit.Test;
public class KnightQuestTest {

    @Test
    public void knightcallQuest(){
        Quest mockQuest = mock(Quest.class);
        KnightImpl k = new KnightImpl(mockQuest);
        k.embarkOnQuest();
        verify(mockQuest, times(1)).embark();
    }

}

 

posted @ 2017-03-19 09:25  fangfan  阅读(256)  评论(0编辑  收藏  举报