I need an absolute beginners guide to using JUnit and Intellij IDEA 9.x together. I'm running JDK 1.6.0_22 on WinXP. I'm looking for answers to the following questions:
I've got experience with other Unit testing frameworks like, PHPUnit and Boost.Test, so I'm primarily concerned with the mechanics of getting all this set up and running in Intellij.
Edit
I'm a complete newb using Intellij.
I'm coming from a command-line background, i.e. C++ dev using vim and handwritten make files on Linux.
I've managed to compile and run some JUnit tests via command line ( downloaded JUnit 4.8.2 and used the -cp swith), but I'm having a heck of a time getting anything set up under Intellij. I tried looking at the online Intellij docs, but haven't found those to be very useful. I looked in Intellij's lib directory and it includes Junit-4.7.jar.
I really need some kind of quick start guide with step by step instructions from initial project creation through successfully running the first unit test.
In eclipse, you go to test class-> right click -> run-> as junit. Somewhat like this we do. Its similar in intellij too. Go to test class right click and run as junits.
IntelliJ IDEA works with multiple testing frameworks out of the box, for example, JUnit, Spock, TestNG, or Cucumber..
Add a new test In your production code in the editor, place the caret at the class for which you want to create a test, press Alt+Enter , and select Create Test. In the Create Test dialog, select the library that you want to use. If you don't have the necessary library yet, you will be prompted to download it.
lib/
).@org.junit.Test
, as per this quick tutorial, IDEA does not require anything further. For any class with this annotation on at least one of its methods, IDEA will give you the option to execute that class as a JUnit test case. (Note: this may only be the case for files in a directory that's marked as "Test Sources" in the project structure, but I haven't tested this. It's a good idea to set your project up like this anyway.)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With