2012-11-29 72 views

回答

2

您只需根據CXXTEST_RUNNING關鍵字的定義,使用編譯器指令封裝有問題的代碼。

例如:

class myClass { 
    public: 
    myClass() {} 
}; 

#ifndef CXXTEST_RUNNING 
int main (int argc, char *argv[]) { 
    // Temporary runner. Typically deleted upon completion 
    // of alternate functionality added later in the project. 
} 
#endif 

在這種情況下,使用CxxTest框架時main()功能將有利於由測試框架創建的main()的忽略。否則,將使用您提供的main()功能。

+0

很好的答案。我在CxxTest用戶手冊中添加了描述這個例子的文檔。 –

相關問題