让我们考虑一下这个简单的测试代码。(注意:assertSomething在这里super简单,但通常我会为手头的任务编写一个更专业的助手,它会查看多个事物并可以报告多个类型错误。)packagehelloimport"testing"funcTestFoo(t*testing.T){assertSomething(t,2+2==4)//line6assertSomething(t,2+3==6)//line7}funcassertSomething(t*testing.T,expectedbool){if!expected{t.Error("Something'snotright")/
让我们考虑一下这个简单的测试代码。(注意:assertSomething在这里super简单,但通常我会为手头的任务编写一个更专业的助手,它会查看多个事物并可以报告多个类型错误。)packagehelloimport"testing"funcTestFoo(t*testing.T){assertSomething(t,2+2==4)//line6assertSomething(t,2+3==6)//line7}funcassertSomething(t*testing.T,expectedbool){if!expected{t.Error("Something'snotright")/