first commit
Some checks failed
CI/CD Pipeline / Test (push) Failing after 22m19s
CI/CD Pipeline / Security Scan (push) Failing after 5m57s
CI/CD Pipeline / Build (amd64, darwin) (push) Has been skipped
CI/CD Pipeline / Build (amd64, linux) (push) Has been skipped
CI/CD Pipeline / Build (amd64, windows) (push) Has been skipped
CI/CD Pipeline / Build (arm64, darwin) (push) Has been skipped
CI/CD Pipeline / Build (arm64, linux) (push) Has been skipped
CI/CD Pipeline / Build Docker Image (push) Has been skipped
CI/CD Pipeline / Create Release (push) Has been skipped
Some checks failed
CI/CD Pipeline / Test (push) Failing after 22m19s
CI/CD Pipeline / Security Scan (push) Failing after 5m57s
CI/CD Pipeline / Build (amd64, darwin) (push) Has been skipped
CI/CD Pipeline / Build (amd64, linux) (push) Has been skipped
CI/CD Pipeline / Build (amd64, windows) (push) Has been skipped
CI/CD Pipeline / Build (arm64, darwin) (push) Has been skipped
CI/CD Pipeline / Build (arm64, linux) (push) Has been skipped
CI/CD Pipeline / Build Docker Image (push) Has been skipped
CI/CD Pipeline / Create Release (push) Has been skipped
This commit is contained in:
47
tests/unit/testcase_test.go
Normal file
47
tests/unit/testcase_test.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package unit
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/smartystreets/goconvey/convey"
|
||||
testcase "github.com/subconverter-go/internal/testing"
|
||||
)
|
||||
|
||||
func TestTestCase(t *testing.T) {
|
||||
convey.Convey("TestCase 测试", t, func() {
|
||||
convey.Convey("基本创建和配置", func() {
|
||||
tc := testcase.NewUnitTest("TC001", "Test")
|
||||
convey.So(tc.ID, convey.ShouldEqual, "TC001")
|
||||
convey.So(tc.Name, convey.ShouldEqual, "Test")
|
||||
convey.So(tc.Type, convey.ShouldEqual, testcase.UNIT)
|
||||
})
|
||||
|
||||
convey.Convey("链式调用", func() {
|
||||
tc := testcase.NewUnitTest("TC002", "Chain").
|
||||
SetDescription("Chain test").
|
||||
AddTag("test")
|
||||
|
||||
convey.So(tc.Description, convey.ShouldEqual, "Chain test")
|
||||
convey.So(tc.HasTag("test"), convey.ShouldBeTrue)
|
||||
})
|
||||
|
||||
convey.Convey("执行状态", func() {
|
||||
tc := testcase.NewUnitTest("TC003", "Execution")
|
||||
tc.SetInput("input").SetExpectation("output")
|
||||
|
||||
// 初始状态
|
||||
convey.So(tc.Status, convey.ShouldEqual, testcase.PENDING)
|
||||
convey.So(tc.ShouldRun(), convey.ShouldBeTrue)
|
||||
|
||||
// 开始执行
|
||||
tc.Start()
|
||||
convey.So(tc.Status, convey.ShouldEqual, testcase.RUNNING)
|
||||
convey.So(tc.IsRunning(), convey.ShouldBeTrue)
|
||||
|
||||
// 完成执行
|
||||
tc.Complete(true, "result", nil)
|
||||
convey.So(tc.Status, convey.ShouldEqual, testcase.PASSED)
|
||||
convey.So(tc.IsSuccessful(), convey.ShouldBeTrue)
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user