试图模拟最后一堂课

时间:2016-06-13 12:30:32

标签: junit mockito powermock

我一直试图模拟最后一堂课(路径)

@Test
public void testShouldCheckIfThereAreAnyChangesInTheFolder() throws Exception {
    Paths paths = PowerMockito.mock(Paths.class);
    Mockito.when(Paths.get("test/test/test")).thenReturn(path);

    fileSystem = path.getFileSystem();
    WatchService watchService = fileSystem.newWatchService();
    fileWatcher = new FileWatcher(path, fileSystem, watchService);

    fileWatcher.listenToFolderChanges();


}

但我一直收到这个错误

org.mockito.exceptions.misusing.MissingMethodInvocationException: when()需要一个必须是'对mock进行方法调用'的参数。 例如:     当(mock.getArticles())thenReturn(文章);

我不想做实际路径的Paths.get(),因为测试一直挂着,因为它听实际的类

0 个答案:

没有答案