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.

Voila!

Navigating between Test and Subject

Limitations

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

This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to Toggle Test

  1. Jason Zaugg says:

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

  2. Michael says:

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

  3. Doug Donohoe says:

    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).

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">