13

The default war and jar archetypes inside Netbeans don't create a src/test/resources and src/test/java directory.

Is there an easy way of creating src/test/resources inside a Maven project without going to the 'Files' tab or creating the directory manually ?

src/test/java gets created when you create a new unit test.

Most of the Netbeans Maven controls are really intuitive, but manually creating the directory is clumsy.

rjdkolb
  • 10,377
  • 11
  • 69
  • 89

2 Answers2

22

Use the new file wizard to create a new folder.

  1. Right click the parent node of the project and choose "New > Folder..." or choose "File > New File > Other > Folder"
  2. Name the folder src/test/java with a parent folder left blank.
  3. Click finish and the Test Packages folder will appear.
  4. Repeat for src/test/resources
  5. It seems a bug prevents the Other Test Sources from being recognised immediately, thus you must reload the pom by right clicking the project > Reload POM.
Brett Ryan
  • 26,937
  • 30
  • 128
  • 163
  • Thanks. It still seems very clumsy and manual. I was hoping for something profound and easy to explain to junior developers. :) – rjdkolb Mar 03 '15 at 05:53
  • 1
    On the positive side to junior devs this method teaches them about the magen strucfure, especially if you get them to go to the console to create the directory structure. IMHO i would probably teach them to use the archtype directly from maven at the command line to help them understand whats going on. – Brett Ryan Mar 03 '15 at 07:06
1

To create new source folder,

  1. Right click on maven project --->Click on Build Path ----->Click on New Source Folder
  2. New source folder window will open, give the name to your folder example - src/test/source
  3. click on Finish
kenlukas
  • 3,616
  • 9
  • 25
  • 36
aniket
  • 11
  • 1