1. Trang chủ
  2. » Cao đẳng - Đại học

Intro GTestpdf

6 4 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 6
Dung lượng 288,82 KB

Nội dung

GTest Testing examples Testing VC++ – Create an empty “Win32 console Application” project – Add “sample1.h”, “sample1.cc” and “sample1_unittest.cc” under the “c:\gtest\sample” folder in[r]

(1)Introduction to GTest(1.6) with VS2010 CSIE Department, NTUT Woei-Kae Chen Building GTest Download gtest-1.6.0.zip Extract gtest-1.6.zip into the “C:\gtest\” folder Double click gtest\msvc\gtest-md.sln Set Configuration to "Debug" gtest.sln GTest for use with Multithreaded Debug (/MTd) gtest-md.sln GTest for use with Multithreaded Debug DLL (/MDd) (2) Building CppUnit Building (VS 2010) – Build Solution  Build  Build Solution – Resulting libraries (gtest/msvc/gtest-md/Debug) You may get a compiled (binary) version of the include and library from my web site GTest Framework and tools GTest – Google C++ Testing Framework Tests for Google Test itself – gtest_unittest.exe: Unit test for GTest – gtest_prod_test.exe: Production test for Gtest (3) CppUnit Configurations Configurations: – – – – Release (): Multihtreaded DLL Debug (d): Debug Multithreaded DLL Multithreaded (): Multithreaded Multithreaded DLL(-md): Multithreaded DLL For example – debug configuration GTest Multithreaded DLL library name is gtest_main-mdd.lib GTest Testing examples Testing (VC++) – Create an empty “Win32 console Application” project – Add “sample1.h”, “sample1.cc” and “sample1_unittest.cc” (under the “c:\gtest\sample” folder) into the project – Create “gtest.cpp” #include <gtest/gtest.h> int main(int argc, char * argv[]) { testing::InitGoogleTest(&argc, argv); RUN_ALL_TESTS(); system("PAUSE"); return 0; }; (4) GTest Testing examples Testing (VC++) – Select active project  Project  Set as StartUp Project  CppUnitTestApp – Select configuration  Build  Configuration Manager  CppUnitTestApp  Debug  Win32 Compile and run the project Automate executing unit test after code building Configuration – Project  Properties  Configuration properties  Build Events  Command Line  "$(TargetDir)$(TargetFileName)“ Re-Build project (5) Automate executing unit test after code building If you double-click on a failure in the console, VC++ will open the file and highlight the line Writing Unit Tests  For VC++ configuration (has been deprecated from VS2010) – Set include directory  Tools Options  Projects and Solutions  VC++ directories  Include files Add gtest/include – Set library directory  Tools  Options  Projects and Solutions  VC++ directories  Library filesAdd gtest/msvc/gtest/Debug (or gtest/msvc/gtest/Release for release)  For every Project – Enable RTTI  Project  Properties  Configuration properties  C/C++  Languageenable Run-Time Type Information  Yes – Add link library  Project Properties  Configuration properties  Linker  Input  Additional dependencies  gtestd.lib (or gtest.lib for release) – Select runtime library (for win32 console app)  Project  Properties  Configuration properties  C/C++  Code Generation Run-time Library  Multithreaded Debug DLL (6) gtest-gbar gtest-gbar – Google Test UI written in C# and runs on Windows and Linux Execute – – – – – Download gtest-gbar-1.2.2-release-win.zip Decompress zip file Double click Guitar.exe Select the executable unit test file Press Go button gtest-gbar (7)

Ngày đăng: 09/06/2021, 00:55

w