Skip to content

Instantly share code, notes, and snippets.

@segunfamisa
Created March 30, 2020 18:20
Show Gist options
  • Save segunfamisa/8b638edce78a7b884af8166959fb861c to your computer and use it in GitHub Desktop.
Save segunfamisa/8b638edce78a7b884af8166959fb861c to your computer and use it in GitHub Desktop.
@Test
fun `$description$`() {
$END$
}
@segunfamisa
Copy link
Author

To use this, in Android Studio (or IntelliJ IDEA),

  • Navigate to Preferences -> Editor -> Live Templates
  • Click on the + icon,
  • Select "Live Template" to create a new template.
  • In the Abbreviation field, enter whatever abbreviation you like and is easy to recall for you (I used "ktest")
  • In the Description field, enter some description that is familiar to you.
  • In the Template text field, enter the text in the gist above.
  • You will probably see a caution that says "No applicable contexts". Click on "Define", and look for Kotlin.
  • Expand "Kotlin" and click on "Class", as we want this to be active in Kotlin classes.
  • Click on "Apply" and you're good to go!

Screenshot below:
Screenshot showing configuration of Live Templates in Android Studio

@fanjavaid
Copy link

fanjavaid commented Mar 31, 2020

Really useful, Thanks!

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