Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add main/java classes to my test/java directory in intellij

I am new to intellij. I am switching from eclispe Kepler.

I do not have a maven project, but I do have a maven directory structure. My classes are in src/main/java with my tests in src/test/java.

My unit tests are complaining because they can't find the classes from src/main/java. What is the proper way to add this to the build path so that my unit tests can find the source?

like image 505
Thom Avatar asked Apr 15 '26 20:04

Thom


2 Answers

  • Right click the "src/main/java" directory and select "Mark directory as > Sources root".
  • Right click the "src/test/java" directory and select "Mark directory as > Test Sources root"

Also, make sure you use packages underneath your source folders.

like image 162
Sean Patrick Floyd Avatar answered Apr 18 '26 08:04

Sean Patrick Floyd


Jetbrains directed me to here: http://www.jetbrains.com/idea/webhelp/configuring-module-dependencies-and-libraries.html. I added the main/java directory as a module dependency under the test module and everything started working.

like image 25
Thom Avatar answered Apr 18 '26 08:04

Thom