Switch between unit test styles of Go and Java

Have you ever asked yourself how to name and structure your automated tests, which assertions you should use and how to implement sub-tests? The answers to these questions make up your test style. Choosing the right style can make a huge difference in how productive you are in maintaining your tests. At Symflower we have developed our own test style optimized for debuggability, readability and understandability. It is the default for our unit test generation and unit test templates. However, in case you prefer a different test style, we now also provide an option to choose between test styles.

You can follow along the example by installing the free version of Symflower for your editor or console. The examples are done in Go but are easily adaptable to other languages. Also, please let us know if you do not see your preferred test style so we can implement it.

Visual Studio Code

Symflower automatically detects your test style but in case you want to overwrite the default: open VS Code’s settings, e.g. Menu > File > Preferences > Settings. Under the Extensions section click on Symflower. Look up the option Test > Generation: Style and change it to your preferred default, e.g. basic for a very simple style. Have a look at the following video to see this feature and actions. For what examples for test styles have a look at our blog post about better table-driven testing.

Command-line interface (CLI) / continuous integration (CI)

Need a different test style when you work with your console or in your CI? No problem, it is also possible to overwrite the test style using Symflower CLI. Simply add the option --test-style=[style-name] to your command, e.g. --test-style=basic.

Your feedback and what’s next

Let us know if you do not see your preferred test style so we can implement it and let us know how you liked this feature. Subscribe to our newsletter to be notified for future posts on coding, testing and new features of Symflower. Feel free to share this article with your colleagues and friends via Twitter, LinkedIn or Facebook, if you want to help make their software testing a little less painful and more rewarding.

Technical | 2022-04-27