Where can I find an example unit test code that can be run? And how? I wrote a test class, but I think I misunderstand something in the documentation, because when I try to compile and run it (VSC: Monkey C: Run Tests) I get these errors:
java -Xms1g -Dfile.encoding=UTF-8 -Dapple.awt.UIElement=true -jar ~/.Garmin/ConnectIQ/Sdks/connectiq-sdk-lin-4.1.7-2022-11-21-562b8a195/bin/monkeybrains.jar -o bin/test_fr255_MyApp.prg -f monkey.jungle;barrels.jungle -y developer_key.der -d fr255 -w -l 3 -O2z --unit-test
ERROR: fr255: MyApp/source/test/MyAppTest.mc:15,16: Cannot find symbol ':error' on type '$.Toybox.Test.Logger'.
ERROR: fr255: MyApp/source/test/MyAppTest.mc:15,16: Cannot determine type for method invocation.
import Toybox.Lang;
import Toybox.Test;
(:test)
class ExtHRMFieldTest {
static var mHeartRateZones as Array<Number> = HR_ZONES_MOCK;
// test that the new func (smaller code size) gives the same result as the old func for each possible HR
(:test)
static function hrZoneTest(logger as Logger) as Boolean {
for (var hr = 0; hr <= 255; hr++) {
var isValidHR = 0 < hr && hr <= 255;
var orig = computeHrZoneOld(hr, isValidHR);
var newer = computeHrZoneNew(hr, isValidHR);
if (orig != newer) {
logger.error("orig: " + orig + ", new: " + newer); // line 16
return false;
}
}
return true;
}
static hidden function computeHrZoneNew(heartRate as Number, isValidHR as Boolean) as Float {
// ..
}
static hidden function computeHrZoneOld(heartRate as Number, isValidHR as Boolean) as Float {
// ..
}
}