如何在Go中撰写未完成的测试 [英] How To Write Pending Tests In Go

查看:83
本文介绍了如何在Go中撰写未完成的测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有合法的方法来写下一个测试用例,我打算稍后编写完整的测试函数?就像mochajs的待定测试一样? >软件包文档用测试来描述这样的例子(* T).Skip


如果不适用于调用Skip方法的* T和* B,则可跳过测试和基准测试:

  if test.Short(){
t.Skip(在短模式下跳过测试)
}
...
}


您提供的信息跳过会在您打开 go test 时显示 -v 标志(在这个例子中,您还需要提供 -short 标志来查看跳过消息)。


Is there legitimate way to write down a test case for which I intent to write full test function later on? As like pending tests of mochajs?

解决方案

The package docs describe such example with testing.(*T).Skip:

Tests and benchmarks may be skipped if not applicable with a call to the Skip method of *T and *B:

func TestTimeConsuming(t *testing.T) {
    if testing.Short() {
        t.Skip("skipping test in short mode.")
    }
    ...
}

The message you provided for Skip will be printed if you launch go test with a -v flag (in this example you'll also need to provide -short flag to see the skip message).

这篇关于如何在Go中撰写未完成的测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆