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

Documentation for running Ginkgo outside of go test #1451

Open
dagan opened this issue Aug 18, 2024 · 2 comments
Open

Documentation for running Ginkgo outside of go test #1451

dagan opened this issue Aug 18, 2024 · 2 comments

Comments

@dagan
Copy link

dagan commented Aug 18, 2024

I have a use case for running Ginkgo tests without go test, and I am curious if any documentation exists for doing that.

I've perused the code base and see that the bulk of test management falls under the internal package, which I can certainly understand. Is there something I've missed that exposes the ability to programmatically launch Ginkgo outside of a go test context?

For my specific use case, I'm hoping to utilize Ginkgo's DSL for defining and organizing tests, the ability to filter tests by labels, and of course the reporters, but all integrated within a larger application with use cases separate from Ginkgo's. At this point, I suspect that compiling the tests and launching them independently is the move viable path forward, but I figured I'd at least ask. :-)

@onsi
Copy link
Owner

onsi commented Aug 19, 2024

hey hey @dagan - this has come up a couple of times in the past. long story short: your best bet is to compile the tests (or ship with a precompiled test binary) an orchestrate running them by shelling out and parsing the JSON reporter format.

Longer answer: given you’ve looked at some of the code you can see that there are ways to get the DSL to run in-process (the internal_integration tests, in particular, provide a pattern for doin this). And I can imagine exposing a mechanism for letting users leverage this themselves. But there will be caveats - chief among them: because of its magic use of global Ginkgo is not thread-safe. Moreover, its (re)use of closures to define the test hierarchy means that test pollution will occur if you try to run the tests in parallel in the same process. This is why Ginkgo orchestrates multiple processes to run in parallel. If you want to be able to run in parallel you’ll want to use the Ginkgo CLI and offload all that complexity to Ginkgo. If you’re ok with just running in series, though then, yeah, there could be options.

But I think you’ll find that a shelling out to a (potentially precompiled) test suite will largely Just Work™ and be good enough for your usecase.

@dagan
Copy link
Author

dagan commented Aug 19, 2024

Thank you for the response, @onsi. I appreciate the time (and very sincerely appreciate the effort that has gone into Ginkgo and Gomega). ✌️

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

2 participants