kotest / kotest-intellij-plugin

The official Kotest plugin for Intellij and Android Studio
Apache License 2.0
175 stars 23 forks source link

Adding Live Templates #310

Closed Kantis closed 1 month ago

Kantis commented 3 months ago

When a user wants to define a new spec, they can:

  1. Create a Kotlin file (Not class) in the desired location, with the name of the spec they want to define.
  2. In the opened file, use one of the provided live templates. For instance fspec to start defining a FunSpec

fspec expands into:

class MyTest : FunSpec({
   test("Foo") {
      1 shouldBe 1
   }
}

Where MyTest is based on the name of the file, and is the first focused location which lets the user change the Spec name if desired. Pressing tab moves the focus to the name of the test (Foo). The user can change the name then press tab again to focus the test body.

IntelliJ also added an import for FunSpec automatically.

Desired feedback:

What spec styles and abbreviations should we use?

So far I have added:

Maybe we can dogfood this one in the wild.. not a lot of users would find the feature w/o us advertising it somewhere.

sksamuel commented 3 months ago

could also just have stringspec, saving 5 chars isn't a huge deal

sksamuel commented 1 month ago

Do we want to merge this in @Kantis ?