How to execute unit tests

Hi all,

I want to write (unit) tests for my widget, but I must be doing some stupid and hopefully simple mistake.

Here is my test code; it is in file "TestHowToTest.mc":
class TestHowToTest
{

(:test)
static function testHowToTest(logger)
{
Test.assertEqual(1,1);
return true;
}

}


I compile with this statement; maybe the "-t" flag is at the wrong place?:
/.../EclipseSDK/connectiq-sdk-mac-2.1.3/bin/monkeyc -t -o /.../TestUnitTest/bin/TestUnitTest.prg -w -y /.../key.. -z /.../TestUnitTest/resources/drawables/drawables.xml:/.../TestUnitTest/resources/layouts/layout.xml:/.../TestUnitTest/resources/strings/strings.xml -m /.../TestUnitTest/manifest.xml /.../TestUnitTest/source/TestHowToTest.mc /.../TestUnitTest/source/TestUnitTestView.mc /.../TestUnitTest/source/TestUnitTestApp.mc -d fr735xt_sim


Monkeyc also logs this warning: "WARNING: UnitTests:11: Class 'RunNoEvil' does not initialize its super class, 'Test'", but I don't know how to fix this.

I start the simulator like this:
/.../connectiq-sdk-mac-2.1.3/bin/connectiq


I try to execute the tests with this command:
/.../connectiq-sdk-mac-2.1.3/bin/monkeydo /.../TestUnitTest/bin/TestUnitTest.prg /t


What happens then is that the simulator window remains "blank" and the terminal outputs this:
...
File pushed successfully
Connection Finished
Closing shell and port
Found Transport: tcp
Connecting...
Connecting to device...
Device Version 0.1.0
Device id 1 name "A garmin device"
Shell Version 0.1.0



I do all this on a Mac.

I have tried a lot of different flavors of the code and the command line commands, but with no success.

Does anyone know where my error is? Of course, I have read the documentation about how to test, but maybe I miss something...

Thanks,
Florian
  • Well, it's not just you--I was able to reproduce this on my Mac with Travis' example (it works fine on Windows). :) I'm not sure what the root cause is, but we'll get it fixed.
  • Okay, I am slightly embarrassed about this, because the answer is pretty simple. On a Mac, you need to run:

    [FONT=courier new]monkeydo path\to\projects\bin\MyApp.prg -t[/FONT]

    The monkeydo command on Windows is a batch file that takes a '/t' flag, but on Mac it's a bash script that accepts the '-t' flag. We only have it documented the Windows way, which is the cause for confusion (and if it makes you feel better, I didn't realize it was different on a Mac either). We're going to update the scripts to accept both '/t' and '-t', and we'll update the documentation, too.
  • The enhancements to the scripts are available in the 2.2.1 release.
  • Okay, I am slightly embarrassed about this, because the answer is pretty simple. On a Mac, you need to run:

    [FONT=courier new]monkeydo path\to\projects\bin\MyApp.prg -t[/FONT]

    The monkeydo command on Windows is a batch file that takes a '/t' flag, but on Mac it's a bash script that accepts the '-t' flag. We only have it documented the Windows way, which is the cause for confusion (and if it makes you feel better, I didn't realize it was different on a Mac either). We're going to update the scripts to accept both '/t' and '-t', and we'll update the documentation, too.


    The enhancements to the scripts are available in the 2.2.1 release.



    Hi Brandon,

    I just saw your replies from October and today. With "-t" and 2.2.1, I can run my tests :o now. That will keep me busy for the next evenings getting rid of my "//TODO unit test" markers :p. Anyway, with 2.2.1 and "/t", it still does not work. This is just for your information. I am happy now anyway...

    Thanks & regards,
    Florian