diff --git a/Spec_test.go b/Spec_test.go index 91f5682..2146f69 100644 --- a/Spec_test.go +++ b/Spec_test.go @@ -1569,7 +1569,7 @@ func TestRunSuite_spectAsSuite(t *testing.T) { suite2.Test("tst2", func(t *testcase.T) { name2 = t.Name() }) dtb := &doubles.TB{} - testcase.RunSuite(dtb, suite1, suite2.AsSuite()) + testcase.RunSuite[testcase.Suite](dtb, suite1, suite2.AsSuite()) assert.True(t, strings.HasSuffix(name1, "tst1")) assert.True(t, strings.HasSuffix(name2, "tst2")) diff --git a/Suite.go b/Suite.go index 9322766..8e3023d 100644 --- a/Suite.go +++ b/Suite.go @@ -33,7 +33,7 @@ type OpenSuite interface { // RunSuite is a helper function that makes execution one or many Suite easy. // By using RunSuite, you don't have to distinguish between testing or benchmark execution mod. // It supports *testing.T, *testing.B, *testcase.T, *testcase.Spec and CustomTB test runners. -func RunSuite[TBS anyTBOrSpec](tb TBS, contracts ...Suite) { +func RunSuite[S Suite, TBS anyTBOrSpec](tb TBS, contracts ...S) { if tb, ok := any(tb).(helper); ok { tb.Helper() } @@ -46,7 +46,7 @@ func RunSuite[TBS anyTBOrSpec](tb TBS, contracts ...Suite) { } } -func RunOpenSuite[TBS anyTBOrSpec](tb TBS, contracts ...OpenSuite) { +func RunOpenSuite[OS OpenSuite, TBS anyTBOrSpec](tb TBS, contracts ...OS) { if tb, ok := any(tb).(helper); ok { tb.Helper() } diff --git a/Suite_test.go b/Suite_test.go index 6021ab3..cfe4414 100644 --- a/Suite_test.go +++ b/Suite_test.go @@ -199,3 +199,22 @@ func TestSpec_AsSuite_merge(t *testing.T) { // TODO: cover further } + +type SampleContractType interface { + testcase.Suite + testcase.OpenSuite +} + +func SampleContracts() []SampleContractType { + return []SampleContractType{} +} + +func ExampleRunSuite() { + s := testcase.NewSpec(nil) + testcase.RunSuite(s, SampleContracts()...) +} + +func ExampleRunOpenSuite() { + s := testcase.NewSpec(nil) + testcase.RunOpenSuite(s, SampleContracts()...) +}