cicdtest/math/math_test.go

45 lines
831 B
Go

package math
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestMath(t *testing.T) {
Convey("Given two numbers 2 and 3", t, func() {
a := 2
b := 3
Convey("When we add them", func() {
result := Add(a, b)
Convey("The result should be 5", func() {
So(result, ShouldEqual, 5)
})
})
Convey("When we multiply them", func() {
result := Multiply(a, b)
Convey("The result should be 6", func() {
So(result, ShouldEqual, 6)
})
})
})
}
// TestAdd 部分覆盖:只测试 Add 函数
// func TestAdd(t *testing.T) {
// Convey("Given two numbers 2 and 3", t, func() {
// a := 2
// b := 3
// Convey("When we add them", func() {
// result := Add(a, b)
// Convey("The result should be 5", func() {
// So(result, ShouldEqual, 5)
// })
// })
// })
// }