tests failing in core on Windows

can you please link to some resources relating to this. Just for the record: we are on JUnit 5.6.2 at the moment.


yes , junit 5.6.2 has fix the problem .

please can you try this annotation @DisabledOnOs(OS.WINDOWS) on top of that test :sweat_smile: :sweat_smile: is just to see .

but if @gcliff is seeing this issue it does not look fixed :thinking:

@teleivo I have done a build with latest fix made by @achilep but i seem to run into the same error https://pastebin.com/K2vn5G6E

1 Like

@DisabledOnOs(OS.WINDOWS) this annotation disable a test on windows . that test was not suppose to run again .

Screenshot from 2020-07-17 12-23-15

@achilep @teleivo it does fix it https://pastebin.com/fSeUPdhQ

Going to raise a pr

that is not really a fix. lets think about this first. what this is doing is just not running it on Windows. lets first investigate why this is failing on windows. all our automation seems to run on unix like machines so this issue never came up in our development/deployment. currently this means it would fail for everyone developing on windows. if you follow the discussion here https://github.com/spring-io/initializr/issues/862 they found a bug in the end in their own code not in JUnit. Could it be that we are not closing a stream/file properly and somehow this is not an issue on unix like systems. I will have a look.

1 Like

its pretty clear to me now from the error message

Suppressed: java.nio.file.FileSystemException: C:\Users\Cliff\AppData\Local\Temp\junit1581269591057766963\TestingComplexObsSaving_9064e534-7f4b-45be-b266-a78bd131b7fb.mp3: The process cannot access the file because it is being used by another process.

that something is holding on to the file/stream in these 2 tests that are failing. So either its our test that needs to close them or the implementation has a bug that hasn’t been detected. I will investigate further. I will ask @gcliff to try again as soon as I have changed things. Thank you for letting us know :slight_smile:


thanks @teleivo for your investigations on this :cowboy_hat_face:

@gcliff please pull and try again. I adapted the tests to close the input streams it creates. I hope this fixes the tests on Windows :crossed_fingers: let us know


@teleivo its still misbehaving https://pastebin.com/gqJQ61Nv

Out of curiosity whats in the temp dir that cannot be deleted by JUnit? The one it shows when the test fails C:\Users\Cliff\AppData\Local\Temp\junit3772331837415344270 And is there any difference when you run this from your IDE?

and @gcliff please replace

with FileCopyUtils.copy(in, out); with import import org.springframework.util.FileCopyUtils; The FileCopyUtils from Spring closes the in and outputstream.

I would be interested if that is solving it. Then we should have closed all stream/handles on the files JUnit wants to delete. At least that is my hope :sweat_smile:

Am interested to know if my suggestion changed anything for you @gcliff

What I am struggling to understand is


since the OpenmrsUtil.copyFile(in, out); does not close the InputStream I believe the saveObs should then close them.

@dkayiwa what is your take on this?

when i run from the IDE is till get this error stacktrace

i have tried using FileCopyUtils.copy(in, out) from spring and on running the test in the IDE i get https://pastebin.com/JkQ9z5wF

both tests are still failing?

its a appdir for unit tests