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

來源:互聯網
上載者:User

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.

我們將描述如何編寫測試程式,開始使用獨立的斷言條件和構建測試以及測試案例。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.