This repository has been archived by the owner on May 20, 2021. It is now read-only.
/
run_test_cases.go
47 lines (42 loc) · 1.59 KB
/
run_test_cases.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package runner
import (
"github.com/cucumber/cucumber-engine/src/dto"
messages "github.com/cucumber/cucumber-messages-go/v3"
)
type runTestCasesOptions struct {
baseDirectory string
pickles []*messages.Pickle
runtimeConfig *messages.RuntimeConfig
sendCommand func(*messages.Envelope)
sendCommandAndAwaitResponse func(*messages.Envelope) *messages.Envelope
supportCodeLibrary *SupportCodeLibrary
}
// RunTestCasesInParallel runs the given tests cases in parallel
func RunTestCasesInParallel(opts *runTestCasesOptions) (bool, error) {
master := newParallelTestCaseRunnerMaster(opts)
return master.run()
}
// RunTestCasesSequentially runs the given tests cases sequentially
func RunTestCasesSequentially(opts *runTestCasesOptions) (bool, error) {
testRunResult := dto.NewTestRunResult()
isSkipped := opts.runtimeConfig.IsDryRun
for _, pickle := range opts.pickles {
testCaseRunner, err := NewTestCaseRunner(&NewTestCaseRunnerOptions{
BaseDirectory: opts.baseDirectory,
IsSkipped: isSkipped,
Pickle: pickle,
SendCommand: opts.sendCommand,
SendCommandAndAwaitResponse: opts.sendCommandAndAwaitResponse,
SupportCodeLibrary: opts.supportCodeLibrary,
})
if err != nil {
return false, err
}
testCaseResult := testCaseRunner.Run()
testRunResult.Update(testCaseResult, opts.runtimeConfig.IsStrict)
if !isSkipped && !testRunResult.Success && opts.runtimeConfig.IsFailFast {
isSkipped = true
}
}
return testRunResult.Success, nil
}