IdeaGinkgo / Intellij-Ginkgo

Idea plugin for running and viewing ginkgo tests
GNU General Public License v3.0
34 stars 13 forks source link

Support for Table extension #31

Closed chbiel closed 2 years ago

chbiel commented 2 years ago

At the moment they are not collapsible and cannot be executed alone.

Would be a nice feature, if it was supported:

https://github.com/onsi/ginkgo/blob/master/extensions/table/table.go

I don't have enough knowledge about the plugin system, to really help at the moment.

TaylorOno commented 2 years ago

I'll see what I can do adding the run markers and focus test ability is pretty easy I just have to make sure I can parse the output

chbiel commented 2 years ago

that would be really nice. Can I help you somehow?

TaylorOno commented 2 years ago

This branch should have the changes would you be able to help test it?

chbiel commented 2 years ago

Sure, can you point me to a doc how to build it? Or provide the already built plugin?

TaylorOno commented 2 years ago

Sure you have a couple options 1) clone the repo, open it in intellij and run the gradle runide step 2) you can fork the repo and let github actions build the plugin for you (it uses the gradle buildPlugin task) 3) I created a beta release https://github.com/IdeaGinkgo/Intellij-Ginkgo/releases/edit/v0.3.0-beta

At some point I'll also get around to updating the docs with better instructions on building and contributing

chbiel commented 2 years ago

Works nice, thanks!

Only thing I found is, that the Table extension allows something like

func desc(a string, b string) string {
return a + b
}

DescribeTable("something", func(a string, b string),
Entry(desc, "test", "me")
)

In that case the IT block would need to be filtered by the return of the desc function. In this example "something testme". The current state sets the focus to "something desc". So to do this, the desc function would need to be exectued with the rest parameters of the Entry.

I guess this is not easy to do (or even possible).

So i see two options:

  1. Run the function properly when the first parameter of the entry is a function (and call the whole tree if that function e.g. also returns a function again)
  2. Only allow running "Entry" lines, when the first parameter is a string and not a function

I guess the 2) option is easier (or as said even possible).

If you could add that it would be perfect and I think ready to be released.

I will dig into plugin development the next weeks to maybe help out a little bit :)

TaylorOno commented 2 years ago

1 seems like it would be very tricky 2 seems like the best solution for now

It if helps this is how it determines functions are ginkgo functions and marks them as playable https://github.com/IdeaGinkgo/Intellij-Ginkgo/blob/fd983b5e2817a2f1e13995fae8aba8af84be4868/src/main/java/com/github/idea/ginkgo/GinkgoRunLineMarkerProvider.java#L36

This function walks the PSI tree to figure out what the test name and -focus expression should be. Sounds like I would need a way to execute the go functions from inside a java program to get the names right. https://github.com/IdeaGinkgo/Intellij-Ginkgo/blob/fd983b5e2817a2f1e13995fae8aba8af84be4868/src/main/java/com/github/idea/ginkgo/GinkgoRunConfigurationProducer.java#L57