How do I add a directory in intellij?
Answered
@intellij 2021.1.1 community edition
Hi, I want to add a test directory to my project for my test source root.
I have no option to add a directory weher it should be:
"left click src >new>directory", i.e directory does not exist.
I have tried in both 'project file' view and in 'project view'
What should I do to get the option to add a dirctory?
Please sign in to leave a comment.
Hello,
Most probably you cannot create a new directory because src is marked as sources root. To create a directory you can right-click on your project/module name in Project View.
Then right-click on the created directory and select Mark Directory as | Test Sources Root.
Thank you! a lot!
I was tearing my hair... hehe...
Wanted to add to this. Untested, but resolved this by first unchecking 'src' as root and then made all my folders then made the 'main' folder root and test as test root. Intellij automagically marked my 'models' folder as a package folder.

Step 1:
Step 2: Make folder structure
Step 3: Remark folders correctly with 'main' as sources root and 'test' as test sources root

Step 4: Use 'ctr' + 'shift' + 't' inside the source files to create a test and it will make a test file in the test sources root automatically