feat: support run testcases in specified folder path #1198

This commit is contained in:
debugtalk
2022-03-28 18:12:51 +08:00
parent 205657588e
commit 1e91b8cb0f
7 changed files with 121 additions and 17 deletions

View File

@@ -8,6 +8,7 @@ import (
"time"
"github.com/rs/zerolog/log"
"github.com/stretchr/testify/assert"
"github.com/httprunner/httprunner/hrp/internal/scaffold"
)
@@ -283,3 +284,37 @@ func TestRunCaseWithRefAPI(t *testing.T) {
t.Fail()
}
}
func TestLoadTestCases(t *testing.T) {
// load test cases from folder path
tc := TestCasePath(templatesDir + "testcases")
testCases, err := loadTestCases(&tc)
if !assert.Nil(t, err) {
t.Fail()
}
if !assert.GreaterOrEqual(t, len(testCases), 5) {
t.Fail()
}
// load test cases from single file path
tc = demoTestCaseWithPluginJSONPath
testCases, err = loadTestCases(&tc)
if !assert.Nil(t, err) {
t.Fail()
}
if !assert.Equal(t, len(testCases), 1) {
t.Fail()
}
// load test cases from TestCase instance
testcase := &TestCase{
Config: NewConfig("TestCase").SetWeight(3),
}
testCases, err = loadTestCases(testcase)
if !assert.Nil(t, err) {
t.Fail()
}
if !assert.Equal(t, len(testCases), 1) {
t.Fail()
}
}