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
Multiple suites in one package? #130
Comments
it depends on the context but, typically, a and b would be separate packages each with their own test suites. however, you can easily add |
Note, that there will still just be one test suite with some tests that cover |
Hey onsi, First of all, I really love the package you guys have developed (sorry Thanks for the clarification -- I did add b_test, etc (for example I have Also, One thing I did try was to add a "Before Each" to the describe, but I Describe(L0) ( What I was hoping was that the Before Each would happen only once for that My problem is solved -- feel free to close the ticket. I did see that if I |
glad you're enjoying ginkgo+gomega+agouti :) What you're describing is You can emulate the behavior you want with a simple boolean, but I recommend against it. Finally, the problem you're running into is a common pattern in Go. How to share types between packages that are inter-related? In general the answer is to pull out a third package containing all your shared types -- that tends to work fairly well. Though, depending on your contextm having one monolithic package need not be a bad thing. |
One last thought before I close the issue. You could leave all your code in one package but build multiple test-only packages. I've seen that be useful sometimes (e.g. a separate integration suite) |
Right, I am trying to do BeforeAll. I was OK with moving my setup code to BeforeSuite though, so that was OK. Yeah, so I considered moving the types into one package by itself, but that just seemed kind of clunky (and a one file import)... I decided to go wtith the monolithic package. Moving the tests into their own packages is a great idea, that would get me the separation I want actually, and the file structure would actually be pretty good. Thanks! |
@onsi /cc @jayunit100 |
I want to write k8s controller/operator tests within 2 suites, one with envtest controlller manager initialized and listening, and one without. So I can have finegrained negative path testing. For example, I want to to be able to setup a mock k8s api with bad CRs(before the webhook is alive or registered), and see how my controller reacts to correct it , as unit tests. This way, I can setup a set of suites, within the same package like this: 1- clean controller, no CRs preloaded Is that possible? remember that envTest is expensive to start. making a BeforeEach at top level of tests that includes manager start, could be possiblle, but it means starting and stopping manager for every test. |
hey @nabbas-ca I've opened a new issue here to track this. |
Is this possible?
I may just be mistaken on how I should be structuring my Go, but I have a project that looks like this
a/
|------a.go
|------a_suite_test.go
|------a_test.go
|------b.go
I'd lke to have a suite that ONLY tests the functionality in B (and requires different setup/teardown from tests in A)
Is this possible? I've read the docs up and down and it seems like multiple suites are possible, but I have no idea the axiomatic ginkgo way to do it. Maybe it's really obvious and I just missed it.
The text was updated successfully, but these errors were encountered: