I 've been trying to use googletest on Windows CE platform to do unit testing. but gtest doesn' t provide a Windows CE project file, so I had to modify the project myself. here is how to do so:
1. Add a new platform
I added a new Windows CE based platform (Windows Mobile 5.0 Pocket PC SDK (armv4i), for example) in the Configuration Manager of the gtest project.
2. Add below Preprocessor Definitions
In order to compile gtest library for Windows CE, I used below Preprocessor definitions:
"Ndebug;_ Win32_wce = $ (cever);Under_ce; $ (Platformdefines); wince; _ console;$ (Archfam); $ (_ archfam _); _ Unicode; Unicode"
Not all of them are mandatory, but missing the bold ones may cause gtest fail to compile.
3. Create a Windows CE console Project
The sample project is available:
Http://code.google.com/p/rxwen-blog-stuff/source/browse/#svn/trunk/wince/ce_gtest_proj
This project expects to find gtest header file (gtest \ gtest. h) and static library (gtestd. Lib) in googletest folder in parent directory.
Finally, I run the Unit Testing Application on a Windows CE device, and get below outputs in Visual Studio and serial port output respectively. The output shows that the test case passed successfully.
4. Run the application on emulator/device and verify output
Visual Studio output windowdevice serial port output
it's not always necessary to run Unit Testing Application on Windows CE device. if we write our application with care, it's possible that the application can compile and run on both Win32 and Windows CE platform. then we can do unit testing on a normal PC, which will be easier and faster.
but I still wowould like to run the unit testing on Windows CE if our product is supposed to run on it. any subtle differences between Win32 and Win CE may cause the unit testing succeed on one platform but fail on the other. it's wise to do unit testing on the platform that the application will actually run.