您的位置:首页 > 编程语言 > Go语言

【Gtest(Google Test)帮助手册】en-cn

2017-08-10 08:41 246 查看

Gtest官方使用文档

英文文档获得方式:框架生成的执行文件,在命令行 --help 即可获得。

中文翻译版

本操作文档只对使用Gtest (Google Test) 开发的测试用例有效。通过命令,你可以使用以下功能:

 

选择测试用例:

 --gtest_list_tests

     列出所有的测试用例,但并不执行。代码中的用例TEST(Foo, Bar) 显示出的结果是 "Foo.Bar".

  --gtest_filter=POSTIVE_PATTERNS[-NEGATIVE_PATTERNS]

     只运行名字与正模式匹配的测试用例,但不运行与负模式名字相同的用例。

PS:--gtest_filter=执行用例名[-不执行的用例名],用例名可使用部分能配符。

  '?' 匹配任意单字符;

  '*' 匹配任意字符串;

  ':' 分离两种模式。        PS:这一条需要读者自行验证

  --gtest_also_run_disabled_tests

     运行所有用例,包括禁用的用例。

 

执行测试用例:

  --gtest_repeat=[COUNT]

     重复执行用例,使用负数表示一直重复。

  --gtest_shuffle

     洗牌执行,即模式随机顺序执行每个用例集内的用例。

 --gtest_random_seed=[NUMBER]

     设定洗牌模式的随机种子值。(种子的值在1到99999之间,[NUMBER]值为0表示以当前时间作为随机种子。

 

输出信息:

  --gtest_color=(yes|no|auto)

     启用/禁用彩色输出模式。默认的模式是自动模式(auto)

 --gtest_print_time=0

     不打印每次测试经过的时间。

  --gtest_output=xml[:DIRECTORY_PATH\|:FILE_PATH]

     在指定目录或文件路径生成XML报告。默认的FILE_PATH为test_details.xml

 

断言行为:

 --gtest_break_on_failure

     将断言失败转到断点调试。

  --gtest_throw_on_failure

     将断言失败转为C++抛出异常。

  --gtest_catch_exceptions=0

     不将异常报告为测试失败。而是,允许他们崩溃程序或弹出一个弹出窗口(在Windows平台)。

 

除了使用入参的方式(如:--gtest_list_tests),你还可以在环境变量中新建一个配置变量(全部使用大写字母)。例如,禁止输出彩色信息,可以使用入参--gtest_color=no 或者设置环境变量GTEST_COLOR的值为
no
.

 

更多信息,请至官网https://github.com/google/googletest/阅读Gtest文档。如果发现Gtest的Bug(当然,不是指你自己写的Bug),请发邮件至
<googletestframework@googlegroups.com>

 

英文原版

This program contains tests written usingGoogle Test. You can use the

following command line flags to control itsbehavior:

 

Test Selection:

 --gtest_list_tests

     List the names of all tests instead of running them. The name ofTEST(Foo, Bar) is "Foo.Bar".

  --gtest_filter=POSTIVE_PATTERNS[-NEGATIVE_PATTERNS]

     Run only the tests whose name matches one of the positive patterns butnone of the negative patterns.

  '?' matches any single character;

  '*' matches any substring;

  ':' separates two patterns.

  --gtest_also_run_disabled_tests

     Run all disabled tests too.

 

Test Execution:

  --gtest_repeat=[COUNT]

     Run the tests repeatedly; use a negative count to repeat forever.

  --gtest_shuffle

     Randomize tests' orders on every iteration.

 --gtest_random_seed=[NUMBER]

     Random number seed to use for shuffling test orders (between 1 and99999, or 0 to use a seed based on the current time).

 

Test Output:

  --gtest_color=(yes|no|auto)

     Enable/disable colored output. The default is auto.

 --gtest_print_time=0

     Don't print the elapsed time of each test.

  --gtest_output=xml[:DIRECTORY_PATH\|:FILE_PATH]

     Generate an XML report in the given directory or with the given file name.FILE_PATH defaults to
test_details.xml.

 

Assertion Behavior:

  --gtest_break_on_failure

     Turn assertion failures into debugger break-points.

  --gtest_throw_on_failure

     Turn assertion failures into C++ exceptions.

  --gtest_catch_exceptions=0

     Do not report exceptions as test failures. Instead, allow them to crashthe program or throw a pop-up (on Windows).

 

Except for --gtest_list_tests, you canalternatively set the corresponding environment variable of a flag (all lettersin upper-case). For example, to disable colored text output, you can eitherspecify
--gtest_color=noor set the
GTEST_COLOR
environment variable to no.

 

For more information, please read theGoogle Test documentation at https://github.com/google/googletest/. If youfind a bug in Google Test (not one in your own code or tests), please report itto

<googletestframework@googlegroups.com>.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐