You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently found myself doing the following in one of our test suites
funcFoo[T testing.T| testing.B| testing.F](t*T) *Bar {
// test prep stuffvarcleanupFnfunc(func())
switchany(t).(type) {
case*testing.T:
cleanupFn=any(t).(*testing.T).Cleanupcase*testing.B:
cleanupFn=any(t).(*testing.B).Cleanupcase*testing.F:
cleanupFn=any(t).(*testing.F).Cleanupdefault:
log.Fatalf("Error: unsupported type %T", t)
}
cleanupFn(func(){
// test cleanup stuff
})
The cleanup function is common to all of these and is part of the common struct, which is embedded in each of testingT, testing.B, and testing.F.
I was wondering if common could potentially be exposed as an interface?
I'm happy to take a first stab at the PR if this is something the library mainteras would be open to, unless there's a technical reason this shouldn't be the case. Please lmk!
The text was updated successfully, but these errors were encountered:
Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.
@seankhliao This is a proposal though. I'm proposing to make an interface for the common struct under testing. I didn't want to put the effort into implementation before getting a 👍 so I don't waste time implementing.
I recently found myself doing the following in one of our test suites
The cleanup function is common to all of these and is part of the
common
struct, which is embedded in each oftestingT
,testing.B
, andtesting.F
.I was wondering if
common
could potentially be exposed as an interface?I'm happy to take a first stab at the PR if this is something the library mainteras would be open to, unless there's a technical reason this shouldn't be the case. Please lmk!
The text was updated successfully, but these errors were encountered: