Google Test Framework ¶
Linux ¶
- Fedora
# sudo yum install gtest gtest-devel
- From Source
- https://code.google.com/p/googletest/downloads/list에서 최신버전을 받는다.
- 압축을 푼다
make
- https://code.google.com/p/googletest/downloads/list에서 최신버전을 받는다.
예제 소스 ¶
#include <gtest/gtest.h>
#include <iostream>
using namespace std;
int add(int, int);
TEST(main, addTest){
//given
int a = 3;
int b = 5;
//when
int result = add(a, b);
//then
ASSERT_EQ(result, 8);
}
int main(int argc, char ** argv){
testing::InitGoogleTest(&argc, argv);
int retval = RUN_ALL_TESTS();
if(retval != 0) return retval;
}
int add(int a, int b){
return a + b;
}









