在使用Ginkgo框架编写测试时,我注意到按C-c终止正在运行的套件会产生误报。
当您查看代码时,您会注意到此测试应在5秒钟后失败。当我2秒钟后将其终止时,套件会失败,但是结果是,有1个通过测试,0个失败。
在Debian Stretch和Ubuntu 18.04上使用1.11.4和1.12.4版本的行为相同。
套件代码(使用ginkgo bootstrap
自动生成):
package hmmm_test
import (
"testing"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func TestHmmm(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Hmmm Suite")
}
测试代码:
package hmmm_test
import (
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Hmmm", func() {
Context("Dummy test", func() {
It("should fail after 5 seconds", func() {
time.Sleep(5 * time.Second)
Expect(1).NotTo(Equal(1))
})
})
})
测试运行5秒钟时输出(正确的输出):
$ ginkgo
Running Suite: Hmmm Suite
=========================
Random Seed: 1555580607
Will run 1 of 1 specs
• Failure [5.001 seconds]
Hmmm
/tmp/hmmm/hmmm_test.go:10
Dummy test
/tmp/hmmm/hmmm_test.go:11
should fail after 5 seconds [It]
/tmp/hmmm/hmmm_test.go:12
Expected
<int>: 1
not to equal
<int>: 1
/tmp/hmmm/hmmm_test.go:14
------------------------------
Summarizing 1 Failure:
[Fail] Hmmm Dummy test [It] should fail after 5 seconds
/tmp/hmmm/hmmm_test.go:14
Ran 1 of 1 Specs in 5.002 seconds
FAIL! -- 0 Passed | 1 Failed | 0 Pending | 0 Skipped
--- FAIL: TestHmmm (5.00s)
FAIL
Ginkgo ran 1 suite in 5.665592703s
Test Suite Failed
在测试结束之前终止测试时输出(误报):
$ ginkgo
Running Suite: Hmmm Suite
=========================
Random Seed: 1555580763
Will run 1 of 1 specs
^C
Ran 1 of 1 Specs in 1.187 seconds
FAIL! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped
Ginkgo ran 1 suite in 1.85541211s
Test Suite Failed
我希望输出为:
FAIL! -- 0 Passed | 1 Failed | 0 Pending | 0 Skipped
或者1跳过或挂起,但不是Passed
,尤其是测试写失败的情况。
实际输出表明失败,但所有测试...均通过:
FAIL! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped
我想念什么吗?
答案 0 :(得分:0)