mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 07:26:55 +08:00
change: relocate tests
This commit is contained in:
+35
-15
@@ -1,6 +1,7 @@
|
|||||||
package httpboomer
|
package httpboomer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@@ -49,13 +50,39 @@ var demoTestCase = &TestCase{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDumpAndLoadJSON(t *testing.T) {
|
var (
|
||||||
jsonPath := demoTestCaseJSONPath
|
demoTestCaseJSONPath = "demo.json"
|
||||||
err := demoTestCase.dump2JSON(jsonPath)
|
demoTestCaseYAMLPath = "demo.yaml"
|
||||||
if !assert.NoError(t, err) {
|
)
|
||||||
t.Fail()
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
// setup, prepare demo json/yaml testcase file path
|
||||||
|
err := demoTestCase.dump2JSON(demoTestCaseJSONPath)
|
||||||
|
if err != nil {
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
tc, err := loadFromJSON(jsonPath)
|
err = demoTestCase.dump2YAML(demoTestCaseYAMLPath)
|
||||||
|
if err != nil {
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// run all tests
|
||||||
|
code := m.Run()
|
||||||
|
defer os.Exit(code)
|
||||||
|
|
||||||
|
// teardown
|
||||||
|
err = os.Remove(demoTestCaseJSONPath)
|
||||||
|
if err != nil {
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
err = os.Remove(demoTestCaseYAMLPath)
|
||||||
|
if err != nil {
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLoadJSONCase(t *testing.T) {
|
||||||
|
tc, err := loadFromJSON(demoTestCaseJSONPath)
|
||||||
if !assert.NoError(t, err) {
|
if !assert.NoError(t, err) {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
@@ -73,13 +100,8 @@ func TestDumpAndLoadJSON(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDumpAndLoadYAML(t *testing.T) {
|
func TestLoadYAMLCase(t *testing.T) {
|
||||||
yamlPath := "demo.yaml"
|
tc, err := loadFromYAML(demoTestCaseYAMLPath)
|
||||||
err := demoTestCase.dump2YAML(yamlPath)
|
|
||||||
if !assert.NoError(t, err) {
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
tc, err := loadFromYAML(yamlPath)
|
|
||||||
if !assert.NoError(t, err) {
|
if !assert.NoError(t, err) {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
@@ -94,8 +116,6 @@ func TestDumpAndLoadYAML(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var demoTestCaseJSONPath = "demo.json"
|
|
||||||
|
|
||||||
func TestLoadJSONAndRun(t *testing.T) {
|
func TestLoadJSONAndRun(t *testing.T) {
|
||||||
jsonPath := &TestCasePath{demoTestCaseJSONPath}
|
jsonPath := &TestCasePath{demoTestCaseJSONPath}
|
||||||
testcase, err := loadTestFile(jsonPath)
|
testcase, err := loadTestFile(jsonPath)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package httpboomer
|
package httpboomer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -38,22 +37,3 @@ func TestHttpRunner(t *testing.T) {
|
|||||||
t.Fatalf("run testcase error: %v", err)
|
t.Fatalf("run testcase error: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
|
||||||
// setup, prepare demo json testcase file path
|
|
||||||
jsonPath := demoTestCaseJSONPath
|
|
||||||
err := demoTestCase.dump2JSON(jsonPath)
|
|
||||||
if err != nil {
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// run all tests
|
|
||||||
code := m.Run()
|
|
||||||
defer os.Exit(code)
|
|
||||||
|
|
||||||
// teardown
|
|
||||||
err = os.Remove(jsonPath)
|
|
||||||
if err != nil {
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user