MCPcopy Create free account
hub / github.com/commander-cli/commander / FindTests

Method FindTests

pkg/suite/suite.go:73–91  ·  view source on GitHub ↗

FindTests returns a test by the given pattern, if the test was not found an error is returned

(pattern string)

Source from the content-addressed store, hash-verified

71
72// FindTests returns a test by the given pattern, if the test was not found an error is returned
73func (s Suite) FindTests(pattern string) ([]runtime.TestCase, error) {
74 var r []runtime.TestCase
75 for _, t := range s.GetTests() {
76 matched, err := regexp.Match(pattern, []byte(t.Title))
77 if err != nil {
78 panic(fmt.Sprintf("Regex error %s: %s", pattern, err.Error()))
79 }
80
81 if matched {
82 r = append(r, t)
83 }
84 }
85
86 if len(r) == 0 {
87 return []runtime.TestCase{}, fmt.Errorf("could not find test with pattern: %s", pattern)
88 }
89
90 return r, nil
91}
92
93// GetGlobalConfig returns the global configuration which applies to the complete suite
94func (s Suite) GetGlobalConfig() runtime.GlobalTestConfig {

Callers 3

Test_FindTestsFunction · 0.95
Test_FindMultipleTestsFunction · 0.95
executeFunction · 0.80

Calls 2

GetTestsMethod · 0.95
MatchMethod · 0.65

Tested by 2

Test_FindTestsFunction · 0.76
Test_FindMultipleTestsFunction · 0.76