Estoy frente a un problema raro aquí ...JUnit Regla TemporaryFolder lanza arbitrariamente una IOException
Tengo un JUnit la implementación de algunas pruebas. Esta clase tiene el siguiente aspecto:
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
}
}
Esta clase de prueba solía funcionar en mi entorno anterior y todavía lo hace en Continuum.
Sin embargo, cuando se lanza desde Eclipse ninguna, alguna o todas las pruebas de forma arbitraria lanzar una IOException
tales como:
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)
Tengo exactamente el mismo problema al ejecutar JUnit JUnit 4.9 o 4.10 ...
¿Cómo puedo solucionar eso para que funcione correctamente?
Eso debería funcionar. ¿Qué 'Runner' estás usando para ejecutar las pruebas? ¿Son concurrentes? Es posible que desee depurar más, es decir, que la variable 'folder' también vea dónde apunta cuando se produce el problema. –
¿Puedes decir lo que estás haciendo en las pruebas? ¿Estás escribiendo en los archivos? Además, ¿ejecuta la indexación de Windows? –
Sí, el objetivo del programa es procesar datos y escribir un archivo como salida. No se está ejecutando la indexación de Windows. –