Код: Выделить всё
@TempDir
static Path tempDir;
static Path tempFile;
// ...
@BeforeAll
public static void init() throws IOException {
tempFile = Path.of(tempDir.toFile().getAbsolutePath(), "test.txt");
if (!tempFile.toFile().createNewFile()) {
throw new IllegalStateException("Could not create file " + tempFile.toFile().getAbsolutePath());
}
// ...
}
Я что-то упустил? Это работает, поэтому я думаю, что все в порядке, но мне было интересно, есть ли более чистый способ создать новый файл непосредственно с помощью API JUnit 5.
Подробнее здесь: https://stackoverflow.com/questions/666 ... in-junit-5
Мобильная версия