Skip to content

Instantly share code, notes, and snippets.

@alexfdz
Last active October 25, 2017 09:38
Show Gist options
  • Save alexfdz/77536305decbfed12d23fb88e16d03d7 to your computer and use it in GitHub Desktop.
Save alexfdz/77536305decbfed12d23fb88e16d03d7 to your computer and use it in GitHub Desktop.
IntelliJ live template for mocked delegates
  1. Add a custom.xml file to:
  • Windows: <your_user_home_directory>.IntelliJ IDEA<version_number>\config\templates
  • Linux: ~IntelliJ IDEA/config/templates
  • macOS: ~/Library/Preferences/IntelliJ IDEA/templates
  1. Add the content (next snippet)
  2. Restart IntelliJ

gif

<templateSet group="custom">
<template name="mock" value="private final $CLASS$ $CAMELCASE_CLASS$ = org.mockito.Mockito.mock($CLASS$.class);" description="private final mock" toReformat="false" toShortenFQNames="true" useStaticImport="true">
<variable name="CLASS" expression="classNameComplete()" defaultValue="" alwaysStopAt="true" />
<variable name="CAMELCASE_CLASS" expression="camelCase(CLASS)" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
</templateSet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment