How to run test from command line on Mac OS?

I'm failing to start unit tests from a command line on Mac OS. 

java -classpath ~/Library/Application\ Support/Garmin/ConnectIQ/Sdks/connectiq-sdk/bin/monkeybrains.jar com.garmin.monkeybrains.monkeydodeux.MonkeyDoDeux -f bin/late.prg -d fenix6 -s ~/Library/Application\ Support/Garmin/ConnectIQ/Sdks/connectiq-sdk/bin/shell -t

Prints: 

Error: Symbol Not Found Error

Details: Failed invoking <symbol>

Stack:

Encountered an app crash.

And more specific:

java -classpath ~/Library/Application\ Support/Garmin/ConnectIQ/Sdks/connectiq-sdk/bin/monkeybrains.jar com.garmin.monkeybrains.monkeydodeux.MonkeyDoDeux -f bin/late.prg -d fenix6 -s ~/Library/Application\ Support/Garmin/ConnectIQ/Sdks/connectiq-sdk/bin/shell -t test

Error: Symbol Not Found Error

Details: Failed invoking <symbol>

Stack:

------------------------------------------------------------------------------

Executing test test...

ERROR

Encountered an app crash.

The paths are valid, tests/ folder with tests.mc included in monkey.jungle with one test: 

(:test)
function test(logger){
return true;
}

prg was compiled with --unit-test 

What could be wrong? 

Thanks for guidance. I need to do it from a command line to automate it. 

  • Run it from Eclipse and note the command line in the console window, and see what's different.

  • I'm sure this isn't helpful, but someone else on MacOS reported the exact same problem:

    https://forums.garmin.com/developer/connect-iq/f/discussion/257810/error-occurred-when-running-unit-tests-with-the-command-monkeydo-in-vscode-s-terminal/1231425#1231425

    I don't have a Mac available for this purpose so I can't reproduce it myself.

    Maybe file a bug report?

    If it works in Eclipse and/or VS Code, and the output of the console window isn't sufficient, you could try running dtruss to see *exactly* what is happening (at the system call level):

    https://stackoverflow.com/questions/31045575/how-to-trace-system-calls-of-a-program-in-mac-os-x

    You will get a *huge* log file tho. (I would recommend attaching dtruss just before you run unit tests in Eclipse/VS Code, rather than launching the app with dtruss.)

    You also may have to temporarily disable SIP (System Integrity Protection).

  • Okay, I got super bored and tried this in a VM.

    The following worked for me:

    CIQ_HOME=path/to/my/sdk
    cd path/to/my/project
    #build prg
    "$CIQ_HOME/monkeyc" -y path/to/my/dev/key -f monkey.jungle -d fenix6 --unit-test -o bin/test.prg
    #start sim
    "$CIQ_HOME/ConnectIQ"
    #run test
    "$CIQ_HOME/monkeydo" bin/test.prg fenix6 -t

    But then again, when I do it your way (typing in the full java command with jar path and classpath), it also works. So I'm not sure if this will work for you.

    Idk if it helps, but I'm using OpenJDK 15.0.2 via homebrew.

    The sad thing is that when a test fails, the command exit code is still 0 (same as when tests are successful), so you have to literally grep for "FAIL" to know if tests failed, I guess.

  • Also, the error you reported is the same one that I see if I don't have at least one function annotated with :test.

     - When you look at the .prg.debug.xml file, do you see your test function in <functions>? Do you see the compiler-generated function runTests?

    - Have you tried adding your test function to the standard View.mc or App.mc files in the standard location (source/), instead of overriding the source path in the jungle?

  • Ha! Thanks! I tried your approach and did the only change in vars and quotes. And it works! The full dummy script that works for me is: 

    GarminHOME=~/Library/Application\ Support/Garmin/ConnectIQ/Sdks/connectiq-sdk/bin

    DEVICE="fenix6"

    connectiq
    monkeyc --unit-test -o bin/test.prg -y ../developer_key.der -f monkey.jungle -d $DEVICE

    java -classpath "$GarminHOME/monkeybrains.jar" com.garmin.monkeybrains.monkeydodeux.MonkeyDoDeux -f bin/test.prg -s "$GarminHOME/shell" -d $DEVICE -t test

    Thank you!

    … Now, this will be easy to automate testing across all devices and all configurations on a single run.