2

In my project, I am extracting the test data to some location which needs to be used by junit tests. When I run my test from eclipse they run fine but when I run them from idea they fail because they could not locate the data.

I am extracting data at in my projects root Folder.

I am using following code for locating the data on disk

TestData.class.getProtectionDomain().getCodeSource().getLocation().getFile() 

In eclipse it returns

F:\dev\shopping\testData

but in Idea it returns

F:\dev\out\test\testData

Can someone explain this behavior?

1
  • IntelliJ manages the project files different. By default, out is configured as folder for the compiled binaries, test is the sources root for test classes, etc. Commented Mar 26, 2015 at 12:31

1 Answer 1

1

IntelliJ puts all binary files in the out/ folder per default (which also means that that will be the working directory).

You can change that folder for your entire project or for certain modules by going to File -> Project Structure...

More information here: https://www.jetbrains.com/idea/help/configuring-module-compiler-output.html

You can just change this folder to be the same as in Eclipse or provide some other method of finding your test data.

Besides that, you could also just change the working directory of your run configuration to match the one Eclipse is using as well. More information on that here: https://www.jetbrains.com/idea/help/run-debug-configuration-application.html

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.