Issues running unit-test of barrel on mac.

Former Member
Former Member
(I'm using sdk 3.0.7, on Mojave 10.14.2)

So I just created a new barrel.

Then added a file "Tests.mc", with the following content:

(Am I doing it correctly? I tried following https://developer.garmin.com/connect...ble-libraries/ but this is the first time I've added some tests to an connect-iq app)

module MatchpointBarrel {

// Unit test to check if 2 + 2 == 4
(:test)
function myUnitTest(logger) {
var x = 2 + 2; logger.debug("x = " + x);
return (x == 4); // returning true indicates pass, false indicates failure
}

// Unit test to check if 2 + 2 == 4
(:test)
function myUnitTestTwo(logger) {
var x = 2 + 2; logger.debug("x = " + x);
return (x == 5); // returning true indicates pass, false indicates failure
}

}


When I try to run it with "Run No Evil", I get:

Beginning execution of Run No Evil framework.
Building project for 'fr235'... SUCCESS.
Running tests as 'fr235'.
Executing tests for entire project.
/Users/davideverlof/Repo/garmin/connectiq-sdk-mac-3.0.7-2018-12-17-efeb3e3/bin/monkeydo /Users/davideverlof/eclipse-workspace/MatchpointBarrel/bin/test_fr235_MatchpointBarrel.prg fr235 -t
An error occurred executing the Run No Evil framework


If I run it on the command-line, it's just quiet:

$ barrelbuild -o bin/MatchpointBarrel.barrel -f monkey.jungle
$ barreltest -w -y ~/repo/garmin/connectiq-sdk-mac-3.0.7-2018-12-17-efeb3e3/keys/developer_key.der -o bin/MatchpointBarrel.barrel -f monkey.jungle -d fenix3_hr -t
  • I haven't tried to run unit tests from barrels (well I have tried, but there's a blocker that I can't use barrels for my tests. namely that I can't inherit the class in my barrel from my main project where the class is that I want to test, unless I make that class part of my barrel as well, which is pretty senseless thing to do imho)....

    There's luckily a way to do testing without barrels with eclipse linked projects though, I have described this process in 3 articles on my blog, the first one of the articles is here: http://starttorun.info/tutorial-how-to-create-connect-iq-unit-test-project/
  • Former Member
    Former Member
    I found it!!

    The first line `module MatchpointBarrel {` should also have `(:test)` before!
  • indeed, but when you run into the next problem, read my post above yours :)
  • Former Member
    Former Member
    I haven't tried to run unit tests from barrels (well I have tried, but there's a blocker that I can't use barrels for my tests. namely that I can't inherit the class in my barrel from my main project where the class is that I want to test, unless I make that class part of my barrel as well, which is pretty senseless thing to do imho)....

    There's luckily a way to do testing without barrels with eclipse linked projects though, I have described this process in 3 articles on my blog, the first one of the articles is here: http://starttorun.info/tutorial-how-to-create-connect-iq-unit-test-project/


    Thanks for the reponse, if I'll run into other issues I'll might set it up like you propose!
  • Former Member
    Former Member
    indeed, but when you run into the next problem, read my post above yours :)


    I actually went into another blocker, but doesn't seem to be the one you described:

    BUILD: ERROR: fenix3_hr: Monkey Barrel dependencies were detected during Jungle file processing. Barrels are not supported by device: fenix3_hr.

    I don't get when you mean't, everything works fine for me if I use fenix 5, for example.

    This is my barrel:

    module MatchpointBarrel {
    (:Bars) // Notice the annotations above the submodule names
    module Counter {
    // Create a counter var for the "Current Bars"
    var counter = 0;

    // Increment the Bar counter
    function add() {
    counter++;
    return counter;
    }

    // Get the current Bars
    function getCount() {
    return counter;
    }
    }
    }


    This is a test:
    (:test)
    module MatchpointBarrel {
    // Unit test to check if 2 + 2 == 4
    (:test)
    function myUnitTest(logger) {
    MatchpointBarrel.Counter.add();
    MatchpointBarrel.Counter.add();
    return (MatchpointBarrel.Counter.getCount() == 2); // returning true indicates pass, false indicates failure
    }
    }


    And I use it in my project like this:

    using MatchpointBarrel;
    MatchpointBarrel.Counter.add();
    MatchpointBarrel.Counter.add();
    System.println("Count -> " + MatchpointBarrel.Counter.getCount());
    MatchpointBarrel.Counter.add();
    System.println("Count -> " + MatchpointBarrel.Counter.getCount());
  • for
    BUILD: ERROR: fenix3_hr: Monkey Barrel dependencies were detected during Jungle file processing. Barrels are not supported by device: fenix3_hr.

    Check your run config for that target. You'll want the Target SDK Version to be 1.4 and not 1.3 (which may be the default). Barrel support came in 1.4.x
  • I don't get when you mean't, everything works fine for me if I use fenix 5, for example.

    This is my barrel:

    module MatchpointBarrel {
    (:Bars) // Notice the annotations above the submodule names
    module Counter {
    // Create a counter var for the "Current Bars"
    var counter = 0;

    // Increment the Bar counter
    function add() {
    counter++;
    return counter;
    }

    // Get the current Bars
    function getCount() {
    return counter;
    }
    }
    }


    This is a test:
    (:test)
    module MatchpointBarrel {
    // Unit test to check if 2 + 2 == 4
    (:test)
    function myUnitTest(logger) {
    MatchpointBarrel.Counter.add();
    MatchpointBarrel.Counter.add();
    return (MatchpointBarrel.Counter.getCount() == 2); // returning true indicates pass, false indicates failure
    }
    }


    And I use it in my project like this:

    using MatchpointBarrel;
    MatchpointBarrel.Counter.add();
    MatchpointBarrel.Counter.add();
    System.println("Count -> " + MatchpointBarrel.Counter.getCount());
    MatchpointBarrel.Counter.add();
    System.println("Count -> " + MatchpointBarrel.Counter.getCount());


    It works because you don't use classes, you are using modules with global functions, I use class (inheritance) in my projects as I prefer coding in an object oriented style.
  • Former Member
    Former Member
    for
    BUILD: ERROR: fenix3_hr: Monkey Barrel dependencies were detected during Jungle file processing. Barrels are not supported by device: fenix3_hr.

    Check your run config for that target. You'll want the Target SDK Version to be 1.4 and not 1.3 (which may be the default). Barrel support came in 1.4.x


    Okay, interesting. So then I can use barrels for fenix3_hr if I just change target SDK I guess.
  • Former Member
    Former Member
    It works because you don't use classes, you are using modules with global functions, I use class (inheritance) in my projects as I prefer coding in an object oriented style.


    I see. I'm planning to use classes as well, that was just a test.

    Is classes only a problem if you want to inherit from "barrel"-casses to "app-classes"? I was only planning on instantiating "barrel"-classes in my app.

    I did run into some issues with the "Linked"-setup as well, but I'm working on the currently. Im setting up a CI-environment, and then there's a file created named "linkedResources.jungle", which I don't know how to create correctly. So for now I'm just creating it manually in a bash-script. Anyone know how I can generate a "linkedResources.jungle"? Or do I need the Eclipse-plugin for that maybe?
  • Yes. 1.4.x is on the ROW devices. Looks like the APAC devices are still on 1.3.x so your app won't be available for them.