Saturday, March 25, 2017

JUnit | Adding JUnit Library to IntelliJ IDE

IntelliJ is shipped with JUnit versions but they are not added to your project by default. You have to add JUnit libraries to your project manually. I'll show you how to do it the easy way.
  1. Place the cursor at the end of the class name.
  2. The cursor should be exactly at the end of the class name
  3. Press Alt + Enter
  4. Alt-Enter pressed
  5. Click create test and choose the latest JUnit version. If JUnit is not in the module, press Fix
  6. Fix button shown up
  7. Use the JUnit library that comes with IntelliJ and check all the methods you want to test
  8. choose IntelliJ's JUnit distribution
    check the boxes and press ok!
  9. Go to project structure and set the scope to compile
Remark: It's conventional to have the same test class name as the class tested with the suffix 'test'.

No comments:

Post a Comment