Category Archives: IntelliJ

IntelliJ Analyze Stack Trace

The IntelliJ Analyse stack trace is a good tool to add to your bag of tricks.

Simple copy a stack trace to the clipboard, then go to IntelliJ -> Analyze Menu -> Analyze Stack trace

You will see the option to normalize the stacktrace (which is worth choosing), after pressing ok, you will see the output put into the run menu, which will allow you to navigate to classes inside your current project.

This is a nice tool for debugging support stacktraces you may receive, or stack traces originating from a remote server.

TestDox IntelliJ Plugin Reviewed

I’ve recently started using the TestDox plugin with IntelliJ. It’s a nice little tool that fits in well with agile test driven development practices. It’s easy to get started with, either installing it from the IntelliJ plugins repository using your IDE, or downloading it directly from the plugins repository, and copying it into the plugins directory.

The premise on which the test dox plugin is based on is the idea that your test methods should be long sentences using CamelCase to break up words. By doing this your tests become your documentation. The plugin takes this premise, and exposes the following behaviour in IntelliJ:

  1. automatic translation of CamelCase test names to sentences. This is exposed through two different views, which, when coupled with nice navigation synchronisation options, makes it possible to use your tests to understand what the code is meant to do at a high level, and makes it easy to drill down to the specifics when needed.
  2. There is a simple mapping between classes and tests – TestDox knows that HelloWorldTest is the test for HelloWorld. This is configurable to suit your environment (test classname prefixes and suffixes can be specified, as well as test packages).
  3. documentation windows will be context sensitive, using the above mapping to show the appropriate documentation for the class/test currently being edited.
  4. alt-shift-t swapping between the test class and the base class – great for navigation
  5. alt-shift-t will prompt to create a test class if it doesn’t exist. Very cool fr the cases where you have created a class before the test (for whatever reason)

Overall this is a great little tool. There’s only a couple of minor tweaks I’d like to see made to the tool.

  1. The biggest that would be nice for the open source project, would be to make editing the source code of the IntelliJ plugin slightly easier. It would be cool to be able to make slight changes to the software, and help improve the project, but the cost of entry was slightly too high for me.
  2. It would be good for the alt-shift-t auto creation to work both ways. That is I want alt-shift-t to help me automatically create the class as well as the test.
  3. I saw a couple of minor screen repaint issues on 7.0.3 on OSX 10.5

TestDox is a good tool for IntelliJ, and you really should install it and use it.

Creating a Surround in Quote Live Template in IntelliJ

One of the features I like about TextMate is the smart insertion of characters, like when I’m typing text, highlight a word, and type ", TextMate will wrap the word in quotes. Unfortunately IntelliJ doesn’t have this behaviour by default, and makes surrounding some text in quotes messier than what would be preferred.

It is possible to make this task much easier, through the use of live templates. Here is how to do it.

  1. navigate to the add a live template screen via the following path: settings – live templates – add
  2. type "$SELECTION$" as the template text, ensure that the context is suitably broad, give it a meaningful name, and you are done. This can be seen in pictures.

IntelliJ setingslive templatesadd template screen

You will now be able to access the template using the cmd-option (ctrl-alt) t "surround with" shortcut, making it easy to wrap text (code) in quotes using IntelliJ.