Toggle Test

A few years back, I was working with a great team of Java developers who introduced me to IntelliJ. (Thanks!) The team used to even have a plugin, tailored to our coding practices. One indispensible feature was the ‘Toggle Test’, to flick between production code and the corresponding unit test.

That feature has long since been incorporated into IDEA, but has been sadly absent for Scala users. But as of tomorrow, the wait is over! You can use CTRL-SHIFT-T to generate tests, or  to navigate between a test and its subject.

Creating a Test

CTRL-SHIFT-T on the production class, Create New Test…

Choose Language = Scala, and a test framework of your choice.


Navigating between Test and Subject


Currently we only create the empty test class: you can’t generate test methods based on a selection of methods.

Comments below can no longer be edited.

3 Responses to Toggle Test

  1. Avatar

    Jason Zaugg says:

    May 4, 2011

    Specs1 and Scalatest support are not in Build 968, you’ll need to wait one more day for the next nightly.

  2. Avatar

    Michael says:

    May 4, 2011

    Very nice. It’s refreshing to see Scala plugin progress.

  3. Avatar

    Doug Donohoe says:

    July 25, 2011

    It would be nice if the “lightbulb” showed up when you click on the class name, like it does for Java files. When that shows up, pressing “alt-enter” brings up a list of options, including “Create Test”.

    Otherwise, cool! I wasn’t aware of the Ctrl-Shift-T (Command-Shift-T for us Mac folks).

Discover more