Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve IntelliJ Integration. #61

Closed
MicahZoltu opened this issue Feb 7, 2016 · 11 comments
Closed

Improve IntelliJ Integration. #61

MicahZoltu opened this issue Feb 7, 2016 · 11 comments

Comments

@MicahZoltu
Copy link

When using JUnit, I can tell IntelliJ to run a single test by right-clicking on it in the test results window or by right clicking on the test method name in the text area. With Spek tests, I am unable to do either of these things and it appears I can only run entire test classes (not individual given, it or on blocks). When all of the tests are passing this is fine. However, when I have a failing test that I want to debug this means I have to either comment out all other tests in the class or do some other kind of code-level test ignoring in order for my break points to not be hit when other (passing) tests in the suite are run.

Sadly, the inability to run single tests in IntelliJ has driven me away from Spek and back to JUnit for the time being. I'll watch this issue though as I would like to go back at some point. :)

@jskierbi
Copy link

Test structure is not known upfront (unlike JUnit, where whole test structure information can be extracted via reflection prior to execution), so it is not possible to mark single given, it or on to run same way as in JUnit.

However, it may be good idea to add focus idiom to Spek - similar to specta for iOS, where you can add f prefix to make only focused specs run. It would look like this:

given("a calculator") {
    on("add two numbers") {
        it ("returns sum") {}
    }
    fon("substract two numberts") {
        it ("returns difference") {}
        it ("doesn't return sum")
    }
}

in example above, execution result is as follows:

given: a calculator
    on: substract two numbers
        it: returns difference
        it: doesn't return sum

Drawback: your test code has to be modified to run single or a bunch of specs, instead of just telling IDE to run specified test without touching sources.

@hhariri, wdyt?

@hhariri
Copy link
Contributor

hhariri commented Feb 11, 2016

@jskierbi really not in favor of having to modify tests to be honest :/

@yaroslav-ulanovych
Copy link

@jskierbi

Test structure is not known upfront (unlike JUnit, where whole test structure information can be extracted via reflection prior to execution), so it is not possible to mark single given, it or on to run same way as in JUnit.

Sorry, but that's untrue, in scalatest we can able to run single test from a hierarchy

class Test extends FunSpec with Matchers {
  describe("1") {
    describe("2") {
      it("31") {
        println("1")
      }
      it("32") {
        println("2")
      }
    }
  }
}

Screenshot

@jskierbi
Copy link

jskierbi commented Mar 6, 2016

@yaroslav-ulanovych does scalatest come with its own IntelliJ plugin? As for now, for current execution model, without additional logic on the IDE side, for my knowledge this is not possible.

@yaroslav-ulanovych
Copy link

@jskierbi The IntelliJ Scala plugin comes with good ScalaTest support. Anyway I believe pull requests with spek support should be gladly accepted by IntelliJ team.

@hhariri
Copy link
Contributor

hhariri commented Mar 26, 2016

Branch 1.0 should solve this.

@hhariri hhariri closed this as completed Mar 26, 2016
@MicahZoltu
Copy link
Author

@hhariri I just downloaded 1.0.0 and I still don't appear to be able to run individual tests. IntelliJ does show them separately (as before) but I don't see any way to run them in isolation.

Is there something more I need to do in order to run isolated tests?

@hhariri hhariri reopened this Mar 28, 2016
@hhariri
Copy link
Contributor

hhariri commented Mar 28, 2016

Sorry. I was closing a few different issues, and mistakenly closed this one. This current limitation still remains (for now)

@lkogler
Copy link
Contributor

lkogler commented Apr 4, 2016

I've taken a stab at implementing focused tests here: #75

Does this address your issue @Zoltu ?

@MicahZoltu
Copy link
Author

It partially addresses my issue, but I don't think it does so enough to make me switch back from JUnit to Spek for test authoring. I utilize the JUnit IntelliJ integration pretty heavily and use the GUI to run, debug or coverage one test at a item, or a whole class of tests depending on what I am doing. I also sometimes use the run configurations created by doing that to switch back and forth between a couple of different tests.

This fix does allow me to debug a single test, which is a significant improvement, but I still am missing the GUI integration which I heavily rely on. I may try to switch back to Spek again at some point in the future to see how having this feels... but I'm worried that I'll be frustrated at not having the GUI integration working as I would expect.

Also, I believe this won't allow me to do things like use the "re-run all failing tests" feature in IntelliJ, since that will result in all classes with any failing tests being fully re-run.

@hhariri
Copy link
Contributor

hhariri commented May 7, 2016

For now this won't be resolved due to the way Spek is designed and the impossibility of actually running individual functions. If/when we move to scripts and Kotlin provides support for identifying line numbers or expression trees, then we can try and address this issue.

@hhariri hhariri closed this as completed May 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants