6

When I run a test in IntelliJ, it doesn't automatically compile the file first. Is this normal behavior? I know I can use eclipse mode to auto compile when I save, but it seems logical to auto compile before running the file. Is this possible in IntelliJ?

Jeff Storey
  • 56,312
  • 72
  • 233
  • 406
  • 1
    You should look into "Before Launch" option- [more info here](http://stackoverflow.com/a/10858442/579828). Note: If its checked, the whole module/project will be rebuilt, and not only the current test file. – Vic Nov 07 '12 at 00:03
  • Thanks. I looked into this and I edited the defaults, but when I create a new run configuration by right clicking on a test file and clicking run, that doesn't have "make" checked. Is that normal? – Jeff Storey Nov 07 '12 at 04:51
  • Did you check "make" in a relevant configuration under "Defaults" section (JUnit I believe)? – Vic Nov 07 '12 at 07:52
  • I did. It seems that when generating the run configuration from within the file this still doesn't cause the "make" checkbox to be checked. If I go into the run configurations menu and create a new grails configuration, the box is checked. – Jeff Storey Nov 07 '12 at 13:16
  • So the defaults for Grails is checked, but when you have Intellij to autocreate new Grails configuration, the make is unchecked? Perhaps you should [submit a bug request](http://youtrack.jetbrains.com) – Vic Nov 07 '12 at 13:24
  • I will do that, thanks. If you convert your comments into an answer I will accept it. – Jeff Storey Nov 07 '12 at 13:25
  • Issue opened as http://youtrack.jetbrains.com/issue/IDEA-94374 (note this only seems to happen with integration tests) – Jeff Storey Nov 07 '12 at 13:41

2 Answers2

8

There is a "Before Launch" option group under configuration screen, that has "Make" as one of the options. If this option is checked, the whole module/project will be rebuilt prior launching.

If you want this option to persist for all future configurations automatically created by IntelliJ, mark it under relevant configuration in "Defaults" group.

Vic
  • 21,473
  • 11
  • 76
  • 97
2

I have made a macro to Save and Compile mapped to CMD+s

Also made a macro to Save, Compile, and Run mapped to CMD+r

EDIT:

According to this link: http://blog.jetbrains.com/scala/2012/12/28/a-new-way-to-compile/

Using the SBT incrementality type rather than IDEA will better detect modifications to the scala files and function as we expect.

Preferences -> Build -> Compiler -> Scala

BAR
  • 15,909
  • 27
  • 97
  • 185