Tải bản đầy đủ (.pdf) (6 trang)

Intro GTestpdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (288.82 KB, 6 trang )

<span class='text_page_counter'>(1)</span>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).

<span class='text_page_counter'>(2)</span> 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.

<span class='text_page_counter'>(3)</span> 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; };.

<span class='text_page_counter'>(4)</span> 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.

<span class='text_page_counter'>(5)</span> 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.

<span class='text_page_counter'>(6)</span> 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.

<span class='text_page_counter'>(7)</span>

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×