-
-
Notifications
You must be signed in to change notification settings - Fork 650
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
GinkgoT() should implements testing.TB #582
Comments
Hi all, Apologies in advance for the wall-of-text! I too have been looking for functionality along these lines. I am hopeful that you might (re)consider updating I figured it was also worth pointing out that My use case is that I maintain a test runner / assertion library for use with a particular application framework. It has it's own equivalent to This assertion library also supports custom user-supplied assertions. I would like to be able to supply something compatible with We use Ginkgo and Gomega widely within my organisation, and as such I have been reluctant to require any methods that Ginkgo can not supply, but this is becoming increasingly more difficult as I seek to allow integration with third-party testing/assertion libraries that are unknown to me. Obviously this is just one scenario, but I hope it makes the case for a generalised approach to supporting this. For completeness, the following methods from
Additionally, the I think |
hey @jmalloc - this sounds good to me. Would love a PR if you're up for it. |
Hey @jmalloc |
Subscribing- also happy to help- I'm under a deadline so I'm going to make a global of I was trying to use terratest:
|
I think we can start by implements all method that available in testing.TB and then consider that which one should add the behaviour or noop. What do you all think? |
Sorry everyone, I haven't had any time to dedicate to this recently and unfortunately I don't see that changing in the very near term. It usually takes me a while to get to these things. I am still willing to do the PR of course, but if someone gets there before me then that's all the better 👍
This is a good step. I notice that the In my opinion, |
hey all I don't know if you've had a chance to see the Ginkgo 2.0 proposal - but this is in scope (and should land on master before most of the 2.0 stuff) |
i've started working on this - I have
|
@onsi, one recent example where Tracking this back you can see that |
ok I've pushed a commit to master that should implement all the relevant interfaces. |
Thanks @onsi -- working as expected with terratest. |
Thanks @onsi. I've just retested the updated commit with the consul testutil package. i.e. $ go get github.com/onsi/ginkgo@b5fe44d9e12817942846c49d35804c5100e05327 So now have the following in my
When I use ts, err := testutil.NewTestServerConfigT(ginkgo.GinkgoT(), nil) I now see the following error when running the tests:
Looking at the definition of // TB is the interface common to T and B.
type TB interface {
Cleanup(func())
Error(args ...interface{})
Errorf(format string, args ...interface{})
Fail()
FailNow()
Failed() bool
Fatal(args ...interface{})
Fatalf(format string, args ...interface{})
Helper()
Log(args ...interface{})
Logf(format string, args ...interface{})
Name() string
Skip(args ...interface{})
SkipNow()
Skipf(format string, args ...interface{})
Skipped() bool
TempDir() string
// A private method to prevent users implementing the
// interface and so future additions to it will not
// violate Go 1 compatibility.
private()
} Am I misreading something here? It looks like it is impossible to implement |
I've just looked at the implementation of terratest.. // Using an interface that describes testing.T instead of the actual implementation
// makes terratest usable in a wider variety of contexts (e.g. use with ginkgo : https://godoc.org/github.com/onsi/ginkgo#GinkgoT)
type TestingT interface { I assume to make this work for consul I would have modify the testutil package to use a new interface instead of using the actual |
yes that's correct @paulburlumi can you point me at the testutil package? i'm curious to see what it does with that instance of TB. |
@onsi I've now modified the consul testutil package with hashicorp/consul#8647. |
sweet - thanks for pushing that through @paulburlumi |
It looks like things are now working for everyone since commit b5fe44d, so I'm going to close this off now. Please let me know if I missed something. |
welp, here we are again, testing from 1.18.1 SDK has this amazing change in testing.TB interface:
|
Arrgh. Was hopeful for it too. I have test-fixtures (setup and teardown) in the framework I've written at work that use For now I guess I'll resort to running them in the bootstrapped function that uses testing.T |
If anyone is having problems due to the
For any function that takes in the |
oh snap - that's brilliant. would this make sense to pull in to Ginkgo itself? Something like |
I think that would work. Only concern would be that if testing.TB were to add a new function, any caller of that function from on ginkgoTB would get a NPE. https://go.dev/play/p/WK2gl6HctI1 If that's an acceptable tradeoff I can make a PR for this. |
I think that's a fine tradeoff and would prompt the introduction of that function to |
PR: #1333 |
I found that I cannot parse
GinkgoT()
as an argument to my test helper code that use both testing and benchmark code because it doesn't haveHelper()
method.For example:
The result from
go test
:The text was updated successfully, but these errors were encountered: