FindTests returns a test by the given pattern, if the test was not found an error is returned
(pattern string)
| 71 | |
| 72 | // FindTests returns a test by the given pattern, if the test was not found an error is returned |
| 73 | func (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 |
| 94 | func (s Suite) GetGlobalConfig() runtime.GlobalTestConfig { |