From a41f2db807963172bd22c7b22ec51bef85ac255e Mon Sep 17 00:00:00 2001 From: ariley Date: Sun, 19 Apr 2020 22:26:07 +0100 Subject: [PATCH] Add warning in log when no tests are run within a suite --- suite/suite.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/suite/suite.go b/suite/suite.go index cdaf9a9..fce5bfa 100644 --- a/suite/suite.go +++ b/suite/suite.go @@ -179,16 +179,20 @@ func Run(t *testing.T, suite TestingSuite) { } func runTests(t testing.TB, tests []testing.InternalTest) { - r, ok := t.(runner) - if !ok { // backwards compatibility with Go 1.6 and below - if !testing.RunTests(allTestsFilter, tests) { - t.Fail() + if len(tests) == 0 { + t.Log("warning: no tests to run") + } else { + r, ok := t.(runner) + if !ok { // backwards compatibility with Go 1.6 and below + if !testing.RunTests(allTestsFilter, tests) { + t.Fail() + } + return } - return - } - for _, test := range tests { - r.Run(test.Name, test.F) + for _, test := range tests { + r.Run(test.Name, test.F) + } } }