Prerequisites for this tutorial
This tutorial is part of a tutorial series:- Set Up a Connect IQ development environment
- 1: Create a Connect IQ data field
- 2: Use dc.draw() calls for layout
- 3: Using string resources
- 4: How to create a unit test project
Create the first unit test
First we’ll create a easy “hello world” Connect IQ unit test to get us started.- Create a new file StepsCarouselTests.mc under the source folder
- In this new file we say hello world and return true to indicate succes:
1 2 3 4 5 |
(:test) function helloWorld(logger) { logger.debug("Hello World"); return true; } |
Running unit tests
Since Connect IQ 2.3.1 it is possible to run unit tests from within the eclipse editor (in previous versions we had to rely on the command line).The first thing we do is a create a no “Run No Evil” run profile, we do this by going to the menu run -> run configurations -> run no evil test. Click on the new launch configuration button in the button bar and create the following test profile (Select the watches you want to run the tests on by ticking the boxes – here we have all available watch targets of this test project enabled):

Now we only have to run the test, click the run button!
You’ll see several simulators flash by and when finished you see the results in the run no evil box, you can drill into the details by clicking on the “>” icon.

Source Code
You can download the full source code from githubUp next
In the next tutorial we’ll learn how to create unit tests which actually evaluate business logic..ads in wordpress
Feedback
Did you like this article?Questions?- Post in the comments section below!
I ‘think’ I have followed your instructions correctly and also check your code in GitHub, but i get the following error when I implement this tutorial using my datafield project. The error I get is:-
BUILD: ERROR: unknown:0: A valid ‘project.manifest’ property was not defined within a jungle file.
I am using the manifest.XML from the test project rather than the project being tested, is this correct?
Much appreciated for any assistance
Not sure if its a Mac only issue, but the tests did not run unless my project folder names didn’t have spaces. I would have an error when trying to load the .prg file from bin folder.