Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running unit tests from currently opened file in IntelliJ IDEA

Is there any way to have IntelliJ run the current MyTest.java file I'm looking at?

Thanks

like image 264
Shane Courtrille Avatar asked Dec 02 '10 21:12

Shane Courtrille


People also ask

How do I run a current file in IntelliJ?

Press ⌃⇧R (macOS), or Ctrl+Shift+F10 (Windows/Linux), to run the file in its current context.

How do I generate test cases automatically in IntelliJ?

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. To do that, click Fix.


1 Answers

Yeah, you can either:

  1. Right click on the file and go to

    Run 'MyTest'

  2. Use the key binding: if the caret is in a method on that method will be run
    • on a Mac: it's Control+Fn+Shift+F10
    • elsewhere: it's Alt+Shift+F10
like image 154
hvgotcodes Avatar answered Sep 29 '22 07:09

hvgotcodes