Здесь я столкнулся со странной проблемой...
У меня есть JUnit, реализующий несколько тестов. Этот класс выглядит следующим образом:
public class MyTest {
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@Test
public void myTest1() throws IOException {
String destinationPath = folder.newFile("destination1.txt").getPath();
// Do things
}
@Test
public void myTest2() throws IOException {
String destinationPath = folder.newFile("destination2.txt").getPath();
// Do things
}
@Test
public void myTest3() throws IOException {
String destinationPath = folder.newFile("destination.txt").getPath();
// Do things
}
}
Этот тестовый класс работал в моей предыдущей среде и до сих пор работает в Continuum.
Тем не менее, при запуске из Eclipse ни один, некоторые или все тесты произвольно не выдают IOException
, например :
java.io.IOException: The system cannot find the path specified
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:883)
at org.junit.rules.TemporaryFolder.newFile(TemporaryFolder.java:53)
at MyTest.myTest2(MyTest.java:50)
. У меня точно такая же проблема с запуском JUnit 4.9 или JUnit 4.10...
Как я могу исправить это, чтобы он работал правильно?