在 Symbian S60 平台进行单元测试
2010-03-16 17:18:00 来源:WEB开发网23 void testParseMsgUid();
24 void testSendMessage();
25 void testSendMessageExceptions();
26
27 private: // data
28 MSmsEngineObserver* iObserver;
29 CMapExampleSmsEngine* iTarget;
30 };
31
32 #endif // TESTHEADER_H
33
4.在 TestSource.cpp文件中创建空执行函数。
1 #include "TestDriver.h"
2 #include "Logger.h"
3
4 void CMapExampleSmsEngineTest::setUp(){}
5 void CMapExampleSmsEngineTest::tearDown(){}
6 void CMapExampleSmsEngineTest::testParseMsgCoordinates(){}
7 void CMapExampleSmsEngineTest::testParseMsgRequestType(){}
8 void CMapExampleSmsEngineTest::testParseMsgUid(){}
9 void CMapExampleSmsEngineTest::testSendMessage(){}
10 void CMapExampleSmsEngineTest::testSendMessageExceptions(){}
注:TestDriver.h是在编译过程中由TestHeader.h生成的。
5.为测试创建最小的Symbian makefile指令: SymbianOSUnit.mmp:
1 // test class definitions & implementations
2 USERINCLUDE .
3 SOURCEPATH .
4 SOURCE TestSource.cpp
5
6 // test target class definitions & implementations
7 USERINCLUDE ..inc
8 SOURCEPATH ..src
9 // SOURCE CMapExampleSMSEngine.cpp // Our tests don’t test actual class yet
10
11 // libraries the test target depends on
12 LIBRARY etext.lib
13
14 // include SymbianOSUnit mmp file from proper
15 // directory depending on relative path and target platform
16 #include "....SymbianOSUnitSymbianOSUnitAppgroups60_3rdSymbianOSUnit.source"
注:CMapExampleSMSEngine源代码被注解停用是因为我们的测试工作还未开始,并且那些组件与其它类相互联系,这使我们需要在目标被测试的时候着意解决的。
6.为测试工程创建一个bld.inf文件:
更多精彩
赞助商链接