The basics for test automation have been in place for a while. However that was more potential for automation that real automation. Too many things, outside the Touch.Unit application, were still missing.
Since that time Rolf has filled those missing pieces, mainly in the Touch.Server tool, to allow Touch.Unit projects to be build, executed on the simulator and/or on devices, and to receive all the test results on a local file for further processing and reporting.
So how do I do that ? All the tools are already available, i.e. it’s all in the stable MonoTouch 5.2.x releases. All it takes is some minimal scripting to adapt it to your application.
Here’s an example (Makefile) of how this can be done for Touch.Unit itself (i.e. the sample tests it includes).
MDTOOL=/Applications/MonoDevelop.app/Contents/MacOS/mdtool MTOUCH=/Developer/MonoTouch/usr/bin/mtouch TOUCH_SERVER=./Touch.Server/bin/Debug/Touch.Server.exe all: build-simulator build-device run run-test: run-simulator run-device $(TOUCH_SERVER): cd Touch.Server && xbuild build-simulator: $(MDTOOL) -v build -t:Build "-c:Debug|iPhoneSimulator" Touch.Unit.sln run-simulator: build-simulator Touch.Server rm -f sim-results.log mono --debug $(TOUCH_SERVER) --launchsim bin/iPhoneSimulator/Debug/TouchUnit.app -autoexit -logfile=sim-results.log cat sim-results.log build-device: $(MDTOOL) -v build -t:Build "-c:Release|iPhone" Touch.Unit.sln run-device: build-device $(MTOUCH) --installdev bin/iPhone/Release/TouchUnit.app # kill an existing instance (based on the bundle id) $(MTOUCH) --killdev com.xamarin.touch-unit rm -f dev-results.log mono --debug $(TOUCH_SERVER) --launchdev com.xamarin.touch-unit -autoexit -logfile=dev-results.log cat dev-results.log
Makefile shows you how to use:
mdtoolto build an existing MonoDevelop solution, Debug or Release;
mtouchto install and kill (running) applications on devices; and
Touch.Serverto start application, including specifying arguments.
All of them can be useful in other circumstances but for our purpose you can simply issue a
make run-test from a terminal window to execute the test cases on both the simulator and a connected device.
p.s. you should all encourage Rolf to blog more often has he’s doing incredible stuff all around MonoTouch.