Tutorial: Run Connect IQ unit tests

In the previous tutorial we learned how to set up our project to be able to do unit testing, in case you didn’t read that article yet I’d advise to read it now as it’s rather essential when you also want to be able to set up unit tests for your own projects. So read the article how to create a unit test project first now. 🙂

Prerequisites for this tutorial

This tutorial is part of a tutorial series:
This tutorial continues where the last tutorial left of. If you did that tutorial you can continue with your code base or you can just download my project here instead.

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:
The contents of the StepsCarouselTests.mc file will be:

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 github

Up next

In the next tutorial we’ll learn how to create unit tests which actually evaluate business logic.
.

Feedback

Did you like this article?Questions?
  • Post in the comments section below!

Leave a Reply