JUnit rules TemporaryFolder - Error on Bamboo

163 views Asked by At

I wrote some UT with the JUnit Rule TemporaryFolder. In my UT, I mock a service to return this directory like this:

@Rule
public TemporaryFolder folder = new TemporaryFolder();
...
@Test
public void myTest(){
    when(myMock.doSomething()).thenReturn(folder.getRoot());
...

Then in the service, folder is used like this:

IOFileFilter filtreBasique = new NameFileFilter(tagRCPName + ".xml", IOCase.INSENSITIVE);
FileUtils.listFiles(folder, filtreBasique, TrueFileFilter.TRUE);

When I run my UT on my computer, it is all OK, but when I try to run it on Bamboo, I have this error:

java.lang.IllegalArgumentException: Parameter 'directory' is not a directory
at org.apache.commons.io.FileUtils.listFiles(FileUtils.java:358)

I cannot figure out why...

1

There are 1 answers

0
bryce On BEST ANSWER

Finally I found my mistake... It has nothing to do with the Rule JUnit...

It was when I tried to list the files in my directories I had a structure like [TEMP_REPO]\test\test and the separators where hard written. So I replace them by System.getProperty("file.separator") and everything went fine.

Hope this could help someone...