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.
我們將描述如何編寫測試程式,開始使用獨立的斷言條件和構建測試以及測試案例。