[ACCEPTED]-Shortcuts for testing out small code snippets in IntelliJ IDEA?-intellij-idea
Take into account IntelliJ Idea's (from 1 version 14) Scratches:
Ctrl+Shift+Alt+Insertand select type
You can use jshell from any command line (or from 4 the IntelliJ terminal).
View > Tool Windows > Terminal (Alt + F12)
user@xyz:~/IdeaProjects/prj$ jshell | Welcome to JShell -- Version 9-ea | For an introduction type: /help intro jshell>
Enter your snippet 3 (you don't need to add
;at the end of the 2 row)
jshell> Set.of("c", "b", "a").size() $1 ==> 3
jshellusing one of the following 1 approaches:
- press Ctrl + D
I have a "CodePlay" project that exists 15 completely locally (i.e. the sources are 14 local and not in the SCM sandbox) and just 13 add standalone classes to it when I need 12 to play around with some simple code.
I understand 11 this isn't exactly what you wanted ("dispose 10 of the whole thing when I close the context") but 9 since IntelliJ will let you open a project 8 in a new window I don't find it to be disruptive 7 of my main work since the "CodePlay" project 6 window can be minimized or closed without 5 affecting the "real" project window.
Yes, there's 4 the overhead of setting it up once, but 3 once the project is set up it loads pretty 2 quickly because there's not much in it and 1 what is in it is pretty short.
My method to test code is using JUnit and 5 a temporary class. In the class I will create 4 a single zero arg method with a JUnit @Test 3 annotation. The code I am playing with will 2 be inside the method, and then a simple 1 key stroke will run that code.
I would also recommend compileonline.com which can be great 1 for testing small snippets
The answer can be found here. Groovy shell (in 12 IDEA) is a command-line application that 11 lets you evaluate Groovy expressions, functions, define 10 classes and run Groovy commands. The Groovy 9 shell can be launched in Groovy projects 8 and in Grails applications.
Stop Ctrl+F2 Click 7 this button to stop the current process.
Close Ctrl+Shift+F4 6 Click this button to close the selected 5 tab of the Run tool window and terminate 4 the current process.
Execute Groovy Code (Ctrl+Enter) Run 3 code, entered in the console.
Help F1 Use this 2 icon or shortcut to open the corresponding 1 help page.
and I'll be trying this myself
More Related questions