Io sono di fronte a un problema strano qui ...JUnit Regola temporaryFolder getta arbitrariamente un'IOException
Ho un JUnit attuare alcuni test. Questa classe è simile al seguente: class
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
}
}
Questo test consente di lavorare nel mio ambiente precedente e lo fa ancora in Continuum.
Eppure, al momento del lancio da Eclipse nessuno, alcune o tutte le prove arbitrariamente gettare un IOException
come ad esempio:
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)
Ho lo stesso problema esatto in esecuzione JUnit 4.9 o JUnit 4,10 ...
Come posso risolvere il problema in modo che funzioni correttamente?
Questo dovrebbe funzionare. Quale 'Runner' stai usando per eseguire i test? Sono concomitanti? Si potrebbe voler eseguire il debug di più, ovvero la variabile 'cartella' anche vedere dove punta quando si verifica il problema. –
Puoi dire cosa stai facendo nei test? Stai scrivendo ai file? Inoltre, hai l'indicizzazione di Windows in esecuzione? –
Sì, lo scopo del programma è elaborare i dati e scrivere un file come output. Nessuna indicizzazione di Windows è in esecuzione. –