Tutorial Set Up JUnit Tests
Tutorial Set Up JUnit Tests
3. Select Modules, then Sources and Right-Click in the empty area to create
a new folder:
1
4. Name your folder test:
5. Click on your newly created folder and mark it as test directory as seen
below:
6. You can now copy the existing test files into the test folder:
2
7. Open the test classes and write an appropriate package name in the first
line. Use Alt+Enter to automatically move it:
8. Next click on the JUnit error below and use Alt+Enter for hints. Select
Add JUnit ‘5.7.0’ to classpath:
3
10. You can now start coding! Click on one of the missing classes and hit
Alt+Enter to create it:
11. Make sure to select src as destination directory for the classes - we want a
clean separation between test and source files!
4
12. Your structure should now look something like this:
5
2. Select Modules, then Sources and Right-Click in the empty area to create
a new folder:
6
3. Name your folder test:
4. Click on your newly created folder and mark it as test directory as seen
below:
5. Get back to your code, click anywhere and hit Alt+Enter to open the
Generate-menu. Select Test. . . .
7
6. Select the following settings - and make sure to hit the Fix button.
8
8. Now that your test class is created, you can click anywhere in it and use
Alt+Enter to generate test methods: