Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Ali BaigCourses Plus Student 120 Points
When I create directory tests and right click > select "Mark Directory as" I see only 1 option Excluded. Using latest IJ
I am unable to create centralize test directory. Right click is not showing me any other option other then Excluded. I am creating directory at top project level by right clicking and selection New > Directory. I am using Windows 10 and latest IJ.
Ido Shenhav4,577 Points
Okay for those who have the same problem, I've figured it out in my case (partly due to the answer Fahad gave, so thank you Fahad!). So it turned out the 'java-unittesting-vendingmachine' folder was marked as Source Root.
All you have to do is unmark it and you can then mark 'src' as Sources Root and 'tests' as Test Sources Root
Here's my directory structure (using the Maven style):
vending-machine <-- module (content root) ├── src │ ├── main │ │ └── java <-- sources root │ │ └── io │ │ └── github │ │ └── adamelliotfields │ │ └── Main.java │ └── test │ └── java <-- test sources root │ └── io │ └── github │ └── adamelliotfields │ └── MainTest.java └── vending-machine.iml
When starting a project in IntelliJ, it creates the
src folder for you.
Go into terminal and generate the rest (assuming you are in the project root folder):
mkdir -p ./src/main/java/io/github/adamelliotfields
mkdir -p ./src/test/java/io/github/adamelliotfields
Then you can go into Project Structure and label your folders as you wish.
Finally, if you're using Maven or Gradle, it will generate all this automatically for you.