Icon for gfsd IntelliJ IDEA

Rapidly write tests in IntelliJ IDEA and Goland with test templates

Test templates help you write and maintain manually-written unit tests more easily and quicker than doing it entirely by hand. The test template generator in our IntelliJ plugin takes care of repetitive boilerplate code, allowing you to focus on the implementation of your test case. Moreover, given the right test framework the Symflower test skeleton feature adds the right checks to the boilerplate of your tests so you type even less.

Let’s give the test templates a whirl: install the Symflower plugin for IntelliJ IDEA and copy the following snippet into a file named “Animal.java”.

public class Animal {
   int numberOfEyes;
   int numberOfLegs;

   public Animal(int eyes, int legs) {
       this.numberOfEyes = eyes;
       this.numberOfLegs = legs;

   public static Animal fromString(String animal) {
       switch (animal) {
           case "cat":
               return new Animal(2, 4);
           case "fly":
               return new Animal(2, 6);
           case "spider":
               return new Animal(8, 8);

       return null;

By right-clicking into the text editor you will see a context menu entry titled “Symflower: Add Unit Test for Function”. Clicking that entry throws you right into your test file with the cursor positioned in a newly generated test case. You can start implementing your test without having to locate your test file or type out the boilerplate code for the test method. Best of all, test templates work with existing test files so you can use them to expand your test suites.

If you prefer even more automation, Symflower can generate entire test cases (with values and mocking!) for you. Simply use the “Symflower: Generate Unit Tests for File” context menu entry or command or enable test generation when saving a file in the plugin’s settings.

We’re thrilled to hear what you think of this and other featuers of Symflower! Leave some feedback and let us know what you are missing for your daily development needs via Twitter, LinkedIn, Facebook or our public issue tracker. Also, don’t forget to follow us and subscribe to our newsletter to get notified on new articles about software development and software testing.

| 2022-06-02