raniejade/kspec

Provide infrastructure for writing IDE and build tools plugin

Closed this issue · 13 comments

Problem

Currently the only way to get IDE and build tools support is via JUnitKSpecRunner. This approach is very limited as you cant run a specific spec.

Possible solutions

  1. JUnit 5 looks promising, especially the test-engine-api and the launcher. If all goes well with it, we don't even need to write any plugins (someone may already did).
  2. Write a custom test engine for KSpec. Currently exploring it, you can checkout this branch.
  1. Ideally it should allow IntelliJ to run/debug on single blocks (describe; context; it)

  2. Personally having a lot of recent experience with RSpec having a command line runner that works at the context/block nearest a given line number is very useful too.

    For example run the spec context nearest line 62 of SomeFeatureSpec

    kspec src/test/org/example/SomeFeatureSpec.kt:62
    

2 would be a "nice to have", but not essential. If implementing is an easy win, then great! (Of course this is also off topic for IntelliJ integration, so it's just noted here as an idea.)

1 is the plan, already have a gist on the approach that I will take but haven't started it yet. A console runner would be great but it will be low priority. When all the plugins is done, writing the console runner will be easy.

Good news

Just realised that writing the console runner will make writing IDE plugin much more easier, so I will be prioritising it. The runner will just be bare, just enough that I can use it to write the IDE plugins.

Yes, just started writing the console runner hopefully I can have something after this weekend.

For running specific example groups and/or examples, I'll be implementing something similar to an XPath query.

Examples:

  • describe: Foo/it: bar
  • /com.example.SampleSpec/context: group/*

I'd think it would be better to use the line number, and then run the enclosing spec / context for that line.

By way of explanation, it descriptions are generally more verbose than is convenient to retype, as is the full context path to a spec.

Of course whatever you give users going to help, I just wanted to throw in a thought.

On 7 May 2016, at 7:31 PM, Ranie Jade Ramiso notifications@github.com wrote:

For running specific example groups and/or examples, I'll be implementing something similar to an XPath query.

Examples:

describe: Foo/it: bar
/com.example.SampleSpec/context: group/*

You are receiving this because you commented.
Reply to this email directly or view it on GitHub

It will be a bit tricky to implement right now, but it will definitely happen. For now I just want something that can be used with IDE plugins.

@jasonm23 I'll be landing #33 soon and work on the IntelliJ plugin. A console runner is included in the PR, you probably want to check it out. Planning to publish the runner via sdkman, for now just build from source.

./gradlew kspec-console-runner:distZip

The runner will be found under kspec-console-runner/build/distributions.

Sample usage:

kspec -s com/example/SampleSpec.kt --cp <classpath> -q "describe: foo/it: bar"

The runner is very simple and probably still have some bugs. Size is around ~20mb because of the kotlin-compiler.