diff --git a/test/caller_test.go b/test/caller_test.go index 15fa4c9..c897896 100644 --- a/test/caller_test.go +++ b/test/caller_test.go @@ -131,15 +131,15 @@ var ( }() // CallerTestError provides the file with the line number of the `Error` // call in the test context implementation. - CallerTestError = path.Join(SourceDir, "context.go:356") + CallerTestError = path.Join(SourceDir, "context.go:333") // CallerReporterErrorf provides the file with the line number of the // `Errorf` call in the test reporter/validator implementation. - CallerReporterError = path.Join(SourceDir, "gomock.go:60") + CallerReporterError = path.Join(SourceDir, "reporter.go:83") // CallerTestErrorf provides the file with the line number of the `Errorf` // call in the test context implementation. - CallerTestErrorf = path.Join(SourceDir, "context.go:374") + CallerTestErrorf = path.Join(SourceDir, "context.go:351") // CallerReporterErrorf provides the file with the line number of the // `Errorf` call in the test reporter/validator implementation. - CallerReporterErrorf = path.Join(SourceDir, "gomock.go:82") + CallerReporterErrorf = path.Join(SourceDir, "reporter.go:105") ) diff --git a/test/context.go b/test/context.go index df6d17c..63cdd0f 100644 --- a/test/context.go +++ b/test/context.go @@ -65,29 +65,6 @@ type Test interface { //nolint:interfacebloat // Minimal interface. Cleanup(cleanup func()) } -// Reporter is a minimal interface for abstracting test report methods that are -// needed to setup an isolated test environment for GoMock and Testify. -type Reporter interface { - // Error reports a failure messages when a test is supposed to continue. - Error(args ...any) - // Errorf reports a failure messages when a test is supposed to continue. - Errorf(format string, args ...any) - // Fatal reports a fatal failure message that immediate aborts of the test - // execution. - Fatal(args ...any) - // Fatalf reports a fatal failure message that immediate aborts of the test - // execution. - Fatalf(format string, args ...any) - // Fail reports a failure message that immediate aborts of the test - // execution. - Fail() - // FailNow reports fatal failure notifications without log output that - // aborts test execution immediately. - FailNow() - // Panic reports a panic. - Panic(arg any) -} - // Cleanuper defines an interface to add a custom mehtod that is called after // the test execution to cleanup the test environment. type Cleanuper interface { diff --git a/test/gomock.go b/test/reporter.go similarity index 91% rename from test/gomock.go rename to test/reporter.go index 0ffd280..6550f1d 100644 --- a/test/gomock.go +++ b/test/reporter.go @@ -9,6 +9,29 @@ import ( "github.com/tkrop/go-testing/mock" ) +// Reporter is a minimal interface for abstracting test report methods that are +// needed to setup an isolated test environment for GoMock and Testify. +type Reporter interface { + // Error reports a failure messages when a test is supposed to continue. + Error(args ...any) + // Errorf reports a failure messages when a test is supposed to continue. + Errorf(format string, args ...any) + // Fatal reports a fatal failure message that immediate aborts of the test + // execution. + Fatal(args ...any) + // Fatalf reports a fatal failure message that immediate aborts of the test + // execution. + Fatalf(format string, args ...any) + // Fail reports a failure message that immediate aborts of the test + // execution. + Fail() + // FailNow reports fatal failure notifications without log output that + // aborts test execution immediately. + FailNow() + // Panic reports a panic. + Panic(arg any) +} + // Validator a test failure validator based on the test reporter interface. type Validator struct { ctrl *gomock.Controller diff --git a/test/gomock_test.go b/test/reporter_test.go similarity index 100% rename from test/gomock_test.go rename to test/reporter_test.go