From c33cb00dbbde3f0636cb5ff1fa65f7dc3e037129 Mon Sep 17 00:00:00 2001 From: Hubert Siwik Date: Wed, 19 Jun 2024 20:49:35 +0200 Subject: [PATCH] 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 --- runner/run_test.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/runner/run_test.go b/runner/run_test.go index 8870844..c5ad413 100644 --- a/runner/run_test.go +++ b/runner/run_test.go @@ -277,6 +277,8 @@ func (s *runTestSuite) TestRunTests_Run() { ShowTime: true, }, s.out) s.Require().NoError(err) + s.Len(res.Stats.Success, 5, "verbose and execute all failed") + s.Len(res.Stats.Skipped, 0, "verbose and execute all failed") s.Equal(res.Stats.TotalFailed(), 0, "verbose and execute all failed") }) @@ -285,33 +287,41 @@ func (s *runTestSuite) TestRunTests_Run() { Include: regexp.MustCompile("0*"), }, s.out) s.Require().NoError(err) + s.Len(res.Stats.Success, 5, "do not show time and execute all failed") + s.Len(res.Stats.Skipped, 0, "do not show time and execute all failed") s.Equal(res.Stats.TotalFailed(), 0, "do not show time and execute all failed") }) - s.Run("execute only test 008 but exclude all", func() { + s.Run("execute only test 8 but exclude all", func() { res, err := Run(s.cfg, s.ftwTests, RunnerConfig{ - Include: regexp.MustCompile("008"), + Include: regexp.MustCompile("-8$"), // test ID is matched in format `-` Exclude: regexp.MustCompile("0*"), }, s.out) s.Require().NoError(err) - s.Equal(res.Stats.TotalFailed(), 0, "do not show time and execute all failed") + s.Len(res.Stats.Success, 1, "execute only test 008 but exclude all") + s.Len(res.Stats.Skipped, 4, "execute only test 008 but exclude all") + s.Equal(res.Stats.TotalFailed(), 0, "execute only test 008 but exclude all") }) - s.Run("exclude test 010", func() { + s.Run("exclude test 10", func() { res, err := Run(s.cfg, s.ftwTests, RunnerConfig{ - Exclude: regexp.MustCompile("010"), + Exclude: regexp.MustCompile("-10$"), // test ID is matched in format `-` }, s.out) s.Require().NoError(err) + s.Len(res.Stats.Success, 4, "failed to exclude test") + s.Len(res.Stats.Skipped, 1, "failed to exclude test") s.Equal(res.Stats.TotalFailed(), 0, "failed to exclude test") }) s.Run("test exceptions 1", func() { res, err := Run(s.cfg, s.ftwTests, RunnerConfig{ - Include: regexp.MustCompile("1*"), - Exclude: regexp.MustCompile("0*"), + Include: regexp.MustCompile("-1.*"), + Exclude: regexp.MustCompile("-0.*"), Output: output.Quiet, }, s.out) s.Require().NoError(err) + s.Len(res.Stats.Success, 4, "failed to test exceptions") + s.Len(res.Stats.Skipped, 1, "failed to test exceptions") s.Equal(res.Stats.TotalFailed(), 0, "failed to test exceptions") }) }