Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a single Junit Test in IntelliJ IDEA

I am new in IntelliJ IDEA and I want to execute a single Junit test as I do in Eclipse but I haven't seen this option

enter image description here

like image 581
en Peris Avatar asked Jul 01 '19 18:07

en Peris


People also ask

How do I create a unit test in IntelliJ?

Add a new testIn 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.


2 Answers

Intellij runs the unit test in context of your selection!

When you place the cursor on the class name, it will run the whole class. If you select a method name, only that method gets executed (upon turning to the menu or context menu).

You can also select a package in the project view and get to corresponding behavior.

like image 196
GhostCat Avatar answered Nov 10 '22 10:11

GhostCat


Open the class where the tests are located and check the part where inteliJ shows the the number of lines, at the beginning of each test method there is a green icon (looks like a play button) just hit that icon and the specific test method will be executed.

like image 22
Halef Spencer Avatar answered Nov 10 '22 11:11

Halef Spencer