As part of my research into doing test driven development on the Windows Mobile platform, I tried to create a “smart device” project level reference.
(See the post Unit Testing Smart Device Projects for more information about using Microsoft Test and unit testing on Windows Mobile)
As I haven’t found the information anywhere else, I thought I’d post my problem and the solution:
When my test project was in Visual Basic, I got this brutal error message:
A reference to xxxxxxxxx could not be added:
A CSharp test project did manage to get to add the reference, but only after getting this message:
Does this mean I’ve finally found something CSharp can do better than VB.Net? Surely not!
After a great deal of messing around, I tried using the Microsoft Test Test Wizard to create the Visual Basic test project. This worked. The reason this worked was that it took a file reference instead.
So there’s your workaround. Use a file reference.
A way of doing Test Driven Development on the Windows Mobile platform in the early days was not particularly easy.
For the development of Webby I created my own NUnit clone that worked inside the exe in debug mode. This worked really well, but it was limited and I would have preferred something that was integrated into the IDE.
The developers of the “Mobile Client Software Factory” at Microsoft Patterns and Practices felt the need to create a unit testing environment that would enable full “test first” development. Recently I had the need to investigate their solution, and have found very good.
The factory provides comprehensive unit tests for the application blocks that come with the factory, but more interestingly it provides a way for you to use the same testing framework.
This article below gives an outline of how tests are structured and how to do it.
The structure of the tests
The test classes utilise the “Visual Studio Team Suite” attribute test markup ([TestClass], [TestMethod] etc).
These test classes are used by two test projects (assemblies):
- A desktop test project for Visual Studio 2005 Team Suite
- A mobile class library for running the unit tests on a mobile device
Both the desktop and mobile projects reside in the same project folder (with different names)
Creating the tests
The following procedures describe how you should create and run unit tests
To create and run unit tests on the desktop
- Create a Visual Studio 2005 Team System Edition test project that will run unit tests on the desktop.
- Add the <TestClass>, <TestMethod>, <TestInitialize>, and <TestCleanup> attributes described earlier to your classes to indicate which are test classes, test methods, initialization methods, and cleanup methods. (TIP: Reference the application exe or dll as a “File Reference”)
- Run these unit tests using Visual Studio 2005 Team System or the TestDriven.NET test runner until all the tests pass.
Next, you can adapt these tests to run on the mobile device. The following procedure describes how you can use the GuiTestRunner utility to run your unit tests in the device emulator or on a mobile device.
To run unit tests in the emulator or on a device
- Add the following projects to your application project:
- GuiTestRunner.csproj from the Tools\CFUnitTester\GuiTestRunner folder
- TestRunner.csproj from the Tools\CFUnitTester\TestRunner folder
- UnitTesting.csproj from the Tools\CFUnitTester\UnitTesting folder
- If you want to use the test utilities in your tests, also add the TestUtilities.csproj project from the Tools\TestUtilities folder. This project includes utilities to help you read application resources, access the application runtime folder, and provides stopwatches for measuring performance.
- Click Add on the File menu, and then click New Project. In the left-side tree view of the Add New Project dialog box, click Windows Mobile 5.0 Pocket PC. In the right-side window of this dialog box, click Class Library. Click OK to add the new project to your existing solution. Use the naming convention for test projects “[Module to be tested].Tests.CF“.
- Close Visual Studio and, in Windows Explorer, move your new Class Library project into same folder as desktop test project. This allows the device test project to share the same files as the desktop test project more easily.
- Re-open Visual Studio, and open your application solution. In Solution Explorer, right-click the References entry for your application project, and then click AddReference. On the Projects tab of the AddReference dialog box, select your test project, and click OK.
- With the device test project selected in Solution Explorer, click Show AllFiles on the Project menu. This reveals all files and folders in the same folder as the desktop test project.
- Select all the test and supporting files in Solution Explorer, right-click, and then click Include in Project.
- Add the compiler directive to select the appropriate test class namespace at compile time.
- In Solution Explorer, right-click your test project, and then click Properties. On the Properties page, click the Devices tab. Change the value for the Output file folder in the Deployment Options section to %CSIDL_PROGRAM_FILES%\GuiTestRunner to ensure that your tests deploy to the same folder as the as the GuiTestRunner utility.
- Deploy and execute the GuiTestRunner utility
Why is web browsing the iPhone so cool then? Well I can’t answer that question with certainty, as I don’t have access to an iPhone.
But I’ve seen a few videos on the subject and will list my thoughts. Feel free to post any things people feel really “make it”.
Powerful features to me are:
- Thumb scrolling
- Thumb zoom (seems awkward, but seems to work)
- Strong animation support throughout to give an “organic” feel. The animations are contextual and enhance the usability of the program.
- Orientation awareness
I think all these features are intrinsic to the iPhone user experience and are not peculiar to safari.
Other interesting features:
- Cool thumbable “multiple page” interface. (Tab substitute)
- “Full Screen” mode just seems to happen intuitively
- Search field “appears” when url field is focused
- I like the bookmarks “slide up”. Much smoother than traditional PPC menus.
I believe the “usability” of applications like this is going to be “expected” in the future. Software developers will really have to take this seriously in order to survive.
I still think Webby will still have much to offer, even in an iPhone world. Stay posted.