dongyao1915
2014-08-20 05:36 阅读 69
已采纳

GO中一个序列中的多个测试用例

Although Go language allows to run multiple test files in a sequence by using the command $go test packagename ,

is there a way to control this sequence using a textfile.

Like for eg: textfile should just contain the names of all the testcase files to be run in a sequence so that the user just modify this textfile to run the desirable testcases

like $go test textfile.txt Is there a way of customizing in this way?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dpkrbe395930 dpkrbe395930 2014-08-20 05:57

    The go test command allows you to specify test functions to run using go test -test.run <regex>. You could, for example, write a little bash script or alias:

    FILE=$1 # first argument
    cat $FILE | while read regex; do # read file one line at a time
        go test -test.run "$regex"
    done
    

    and then you could do ./myscript.sh testFuncs.txt, for example.

    点赞 评论 复制链接分享

相关推荐