mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-12 16:01:27 +08:00
feat: specify output directory
This commit is contained in:
@@ -2,23 +2,15 @@ package har2case
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var harPath string
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
harPath = "../examples/har/demo.har"
|
||||
|
||||
// run all tests
|
||||
code := m.Run()
|
||||
defer os.Exit(code)
|
||||
|
||||
// teardown
|
||||
}
|
||||
var (
|
||||
harPath = "../examples/har/demo.har"
|
||||
harPath2 = "../examples/har/postman-echo.har"
|
||||
)
|
||||
|
||||
func TestGenJSON(t *testing.T) {
|
||||
jsonPath, err := NewHAR(harPath).GenJSON()
|
||||
@@ -31,6 +23,17 @@ func TestGenJSON(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenYAML(t *testing.T) {
|
||||
yamlPath, err := NewHAR(harPath2).GenYAML()
|
||||
log.Printf("yamlPath: %v, err: %v", yamlPath, err)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fail()
|
||||
}
|
||||
if !assert.NotEmpty(t, yamlPath) {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadHAR(t *testing.T) {
|
||||
har := NewHAR(harPath)
|
||||
h, err := har.load()
|
||||
@@ -108,3 +111,10 @@ func TestMakeTestCase(t *testing.T) {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetFilenameWithoutExtension(t *testing.T) {
|
||||
filename := getFilenameWithoutExtension("examples/har/postman-echo.har")
|
||||
if !assert.Equal(t, "postman-echo", filename) {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user