google / google/jimfs

Make it throw!

Open
#32 2 comments 7 reactions 0 assignees View on GitHub
P4
Dominant language
Java
Stars
2.6k
Forks
296
Avg merge
9m
Merged PRs (30d)
7

Description

I always find it difficult to test I/O error handling. Jimfs immensely simplifies writing unit tests for code that interacts with the file system, but it doesn't help with testing the 'bad' path.

I would like to be able to set expectations on a `Path`, e.g. to throw an `IOException` if someone tries to open a channel for it. I was thinking of a new method `Jimfs.newMockFileSystem()` that returns a specialized `MockFileSystem`, which in turn can be used to build `Path` objects that behave how I want.

As I understand it, the goal of Jimfs is to simplify unit testing, so I hope this feature request is not too much out of scope?!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.