mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-22 00:32:11 +08:00
feat: support run testcases in specified folder path #1198
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user