代码改变世界

Google Test Primer(入门) (二)——基本概念

2008-11-08 10:45  ubunoon  阅读(716)  评论(0编辑  收藏  举报

Basic Concepts


基本概念


When using Google Test, you start by writing assertions, which are statements that check whether a condition is true. An assertion's result can be success, nonfatal failure, or fatal failure. If a fatal failure occurs, it aborts the current function; otherwise the program continues normally.

当使用Google Test时,从编写测试条件是否为真断言的语句开始。一个断言的结果可以成功,非致命的失败和致命的失败。如果致命的失败发生了,测试将终止当前函数,否则程序将继续运行。

Tests use assertions to verify the tested code's behavior. If a test crashes or has a failed assertion, then it fails; otherwise it succeeds.

测试使用断言确保测试代码行为,如果测试crash了或者断言失败,测试将失败,否则测试成功。


A test case contains one or many tests. You should group your tests into test cases that reflect the structure of the tested code. When multiple tests in a test case need to share common objects and subroutines, you can put them into a test fixture class.

一个test case(测试案例)包含一个或多个测试。应该组合你的测试到反射出测试代码结构的测试案例中,当一个测试案例中有多个测试需要共享对象和子过程时,应该将它们放置在一个test fixture类中。


A test program can contain multiple test cases.

一个测试程序可以包含多个测试案例


We'll now explain how to write a test program, starting at the individual assertion level and building up to tests and test cases.

我们将描述如何编写测试程序,开始使用独立的断言条件和构建测试以及测试案例。