gtest如何执行部分测试用例
来源:互联网 发布:手机电脑桌面软件2016 编辑:程序博客网 时间:2024/06/08 08:48
开发时候,先写测试是个好习惯,就算不是正式意义上的测试驱动开发,也对开发质量有明显提升。C++开发写测试代码,几种工具里面,我最喜欢gTest. 初上手时,以为它不能选择部分用例单独执行,其实它是提供了这功能的,可以先简单的做到。
假定写了下面这样若干测试用例。
------------------------------------------------------
TEST(case1, functionA_test) {
....
}
TEST(case1, functionB_test) {
....
}
TEST(case2, functionA_test) {
.....
}
TEST(case2, functionB_test){
....
}
TEST(case3, functionA_test) {
....
}
再假定编译出来的程序名test.exe,
比如我们现在想要只跑case2这几个测试,那么一个命令行参数就可以搞定:
--gtest_filter=case2.*
如果想在VS集成环境运行,那么就把这一串加进命令参数:
配置属性=〉调试=〉命令参数 设置
---------------------------------
其实在命令行带/?参数执行编译好的测试程序,就知道gTest这些开关:
附在下面
----------------------------------
This program contains tests written using Google Test. You can use the
following command line flags to control its behavior:
Test Selection:
--gtest_list_tests
List the names of all tests instead of running them. The name of
TEST(Foo, Bar) is "Foo.Bar".
--gtest_filter=POSTIVE_PATTERNS[-NEGATIVE_PATTERNS]
Run only the tests whose name matches one of the positive patterns but
none 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 and
99999, 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 crash the program or throw a pop-up (on Windows).
Except for --gtest_list_tests, you can alternatively set the corresponding
environment variable of a flag (all letters in upper-case). For example, to
disable colored text output, you can either specify --gtest_color=no or set
the GTEST_COLOR environment variable to no.
For more information, please read the Google Test documentation at
http://code.google.com/p/googletest/. If you find a bug in Google Test
(not one in your own code or tests), please report it to
<googletestframework@googlegroups.com>.
- gtest如何执行部分测试用例
- gtest如何测试private成员
- gtest中如何跳出当前测试案例
- gtest在linux下编译测试用例
- 用gtest测试类的私有成员
- 用gtest测试类的私有成员
- google gtest测试框架--简单便用
- 用json文件方式使gtest的测试数据和测试用例分离
- gtest编写第一个测试用例出错及其解决过程
- gtest测试MFC项目
- 测试框架之GTest
- gtest 测试框架
- Gtest各种测试示例
- 测试框架之GTest
- GTest测试私有函数
- 如何执行软件测试
- 如何执行软件测试
- robot framework 如何灵活地执行测试用例和测试套件啊
- 使用OpenCV中cvFindContour函数检测轮廓的心得
- 舌尖上的世界杯
- Baidu百度搜索引擎登录网站 - Blog透视镜
- Simple-Spring-Memcached 使用简介
- 生活的态度
- gtest如何执行部分测试用例
- 弹出框
- 55款超强 jQuery 导航菜单插件
- iOS优秀项目
- Android错误:android out of memory on a xxxxx-byte allocation解决方法
- this kernel requires an x86-64 CPU, but only detected an i686 CPU. unable to boot - please ues a ker
- linux命令后台运行
- for 循环
- Javascript 设计模式 单例