I often forget the processes that are often used in JUnit 5, so I will write them as a memorandum.
What you can do with standard functions. I can't do it, so make a note of the case where you need to make your own.
3.TIPS
Lock the target file so that it cannot be read.
try (
FileChannel fc =
FileChannel.open(Paths.get(""), StandardOpenOption.CREATE, StandardOpenOption.WRITE);
FileLock lock = fc.tryLock()) {
//Operation after lock acquisition
} catch (Exception e) {
//Lock acquisition failure
}
If the file size is small, use commons-io for the following.
assertThat(FileUtils.readFileToString(file1, "UTF-8"),
is(FileUtils.readFileToString(file2, "UTF-8")));
Recommended Posts