pxt-common-packages/libs/tests
Richard Knoll 11fa8efe9f Make forever and pause be top level (#227)
* Moving forever and pause to be top level

* Fixing docs for forever and pause
2018-02-14 15:38:17 -08:00
..
README.md Make forever and pause be top level (#227) 2018-02-14 15:38:17 -08:00
pxt.json Boiler plate for Behaviors Drive Robotics (#201) 2018-01-04 12:47:21 -08:00
targetoverrides.ts Boiler plate for Behaviors Drive Robotics (#201) 2018-01-04 12:47:21 -08:00
tests.ts Make forever and pause be top level (#227) 2018-02-14 15:38:17 -08:00

README.md

tests

A unit test framework

Defining tests

Tests are registered as event handlers. They will automatically run once on start is finished.

tests.test("lgB set speed 10", () => {
    motors.largeB.setSpeed(10);
    pause(100)
    tests.assertClose("speedB", 10, motors.largeB.speed(), 2)
});

Assertions

The library has various asserts that will register fault. Note that since exceptions are not available, assertion failure do not stop the program execution.

  • assert checks a boolean condition
tests.assert("speed positive", motors.largeB.speed() > 0)
  • assert close checks that a numberical value is within a particular range
tests.assertClose("speed", motors.largeB.speed(), 10, 2)
tests