http://code.google.com/p/googletest/

cd /cygdrive/C/source/gtest-1.7.0

g++ -I./include -I. -c ./src/gtest-all.cc

ar -rv libgtest.a gtest-all.o

    • -

[オプション]

結果をXMLに出力 (xml:出力ファイルパス)
'--gtest_output=xml:./test/xxx.xml

テストを指定して実行 (クラス.テスト)
'--gtest-filter = xxx.xxx

テスト一覧を表示
'--gtest_list_tests

    • -

[参考]
ビルド方法
http://inet-lab.naist.jp/google-test-under-current-directory/

テスト作成方法
http://pokotsun.mydns.jp/?s=GoogleTest%E3%81%A7%E5%AD%A6%E3%81%B6

    • -

[テストクラス]

class XXXTest : public ::testing::Test { // テストクラス
protected:
virtual void SetUp() { // 前処理
}
virtual void TearDown() { // 後処理
}
};
TEST_F( XXXTest, TestName ) { // テストクラス, テスト名
}

    • -

[main 関数]

#include "gtest/gtest.h"
int main( int argc, char* argv[] ) {

testing::InitGoogleTest(&argc, argv);

return RUN_ALL_TESTS();
}

    • -

[ビルド]
g++ -I./include -c xxx.cpp
g++ -I./include -I. -c ./src/gtest-all.cc
g++ -o gtest-all.o xxx.cpp

    • -