Files
Patrick Ohly 1db4ec48fe testing: enforce usage of interface instead of testing.T/TB
Production code should not depend on the testing package. Helper packages
should be more flexible and support other implementations like
ktesting.TContext.

Valid exceptions are type assertions.
2026-10-14 15:30:29 +02:00

41 lines
1.1 KiB
Go

/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package utils
import "testing"
// TB is the subset of testing.T and testing.TB that is needed by helpers in
// test/utils and test/integration/framework.
type TB interface {
Cleanup(func())
Error(args ...any)
Errorf(format string, args ...any)
FailNow()
Fatal(args ...any)
Fatalf(format string, args ...any)
Helper()
Log(args ...any)
Logf(format string, args ...any)
Name() string
TempDir() string
}
// This tells the vet printf checker that methods in the interface must be checked.
//
//nolint:forbidigo
var _ TB = &testing.T{}