Skip to content

Commit c33cb00

Browse files
huberts90Hubert Siwik
andauthored
Fix: Verify executed tests taking include/exclude option into account (#320)
* Fix: Verify executed tests taking include/exclude option into account --------- Co-authored-by: Hubert Siwik <[email protected]>
1 parent fd065a0 commit c33cb00

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

runner/run_test.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ func (s *runTestSuite) TestRunTests_Run() {
277277
ShowTime: true,
278278
}, s.out)
279279
s.Require().NoError(err)
280+
s.Len(res.Stats.Success, 5, "verbose and execute all failed")
281+
s.Len(res.Stats.Skipped, 0, "verbose and execute all failed")
280282
s.Equal(res.Stats.TotalFailed(), 0, "verbose and execute all failed")
281283
})
282284

@@ -285,33 +287,41 @@ func (s *runTestSuite) TestRunTests_Run() {
285287
Include: regexp.MustCompile("0*"),
286288
}, s.out)
287289
s.Require().NoError(err)
290+
s.Len(res.Stats.Success, 5, "do not show time and execute all failed")
291+
s.Len(res.Stats.Skipped, 0, "do not show time and execute all failed")
288292
s.Equal(res.Stats.TotalFailed(), 0, "do not show time and execute all failed")
289293
})
290294

291-
s.Run("execute only test 008 but exclude all", func() {
295+
s.Run("execute only test 8 but exclude all", func() {
292296
res, err := Run(s.cfg, s.ftwTests, RunnerConfig{
293-
Include: regexp.MustCompile("008"),
297+
Include: regexp.MustCompile("-8$"), // test ID is matched in format `<ruleId>-<testId>`
294298
Exclude: regexp.MustCompile("0*"),
295299
}, s.out)
296300
s.Require().NoError(err)
297-
s.Equal(res.Stats.TotalFailed(), 0, "do not show time and execute all failed")
301+
s.Len(res.Stats.Success, 1, "execute only test 008 but exclude all")
302+
s.Len(res.Stats.Skipped, 4, "execute only test 008 but exclude all")
303+
s.Equal(res.Stats.TotalFailed(), 0, "execute only test 008 but exclude all")
298304
})
299305

300-
s.Run("exclude test 010", func() {
306+
s.Run("exclude test 10", func() {
301307
res, err := Run(s.cfg, s.ftwTests, RunnerConfig{
302-
Exclude: regexp.MustCompile("010"),
308+
Exclude: regexp.MustCompile("-10$"), // test ID is matched in format `<ruleId>-<testId>`
303309
}, s.out)
304310
s.Require().NoError(err)
311+
s.Len(res.Stats.Success, 4, "failed to exclude test")
312+
s.Len(res.Stats.Skipped, 1, "failed to exclude test")
305313
s.Equal(res.Stats.TotalFailed(), 0, "failed to exclude test")
306314
})
307315

308316
s.Run("test exceptions 1", func() {
309317
res, err := Run(s.cfg, s.ftwTests, RunnerConfig{
310-
Include: regexp.MustCompile("1*"),
311-
Exclude: regexp.MustCompile("0*"),
318+
Include: regexp.MustCompile("-1.*"),
319+
Exclude: regexp.MustCompile("-0.*"),
312320
Output: output.Quiet,
313321
}, s.out)
314322
s.Require().NoError(err)
323+
s.Len(res.Stats.Success, 4, "failed to test exceptions")
324+
s.Len(res.Stats.Skipped, 1, "failed to test exceptions")
315325
s.Equal(res.Stats.TotalFailed(), 0, "failed to test exceptions")
316326
})
317327
}

0 commit comments

Comments
 (0)