Skip to content

Instantly share code, notes, and snippets.

@seanjreilly
Last active February 19, 2024 12:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanjreilly/9d943b216f67200dfd78ac9e0f1f5e95 to your computer and use it in GitHub Desktop.
Save seanjreilly/9d943b216f67200dfd78ac9e0f1f5e95 to your computer and use it in GitHub Desktop.
An IntelliJ live template for JUnit5 unit tests in Java.
<templateSet group="JUnit5">
<template name="test" value="@org.junit.jupiter.api.Test&#10;@org.junit.jupiter.api.DisplayName(&quot;$name$&quot;)&#10;void $method$() throws Exception {&#10; $END$&#10;}" description="JUnit 5 test" toReformat="true" toShortenFQNames="true" useStaticImport="true">
<variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="method" expression="camelCase(name)" defaultValue="" alwaysStopAt="false" />
<context>
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
</templateSet>
@seanjreilly
Copy link
Author

seanjreilly commented Jan 24, 2020

A live template for JUnit5 unit tests in Java for IntelliJ. It uses the @DisplayName annotation and variables so you don't need to type the method name, just a test name. Installation instructions are here.

Once it's installed, type test and hit TAB in a Java file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment