pxt-ev3/libs/tests
Peli de Halleux 7581b5af9e
Drift support (#926)
* upgrading drift support

* updated showports

* typos
2019-09-29 09:49:13 -07:00
..
README.md renaming 'set speed' to 'run' (#327) 2018-02-19 07:35:08 -08:00
pxt.json Behaviors Driven Robotics (#178) 2018-01-04 12:55:30 -08:00
targetoverrides.ts Drift support (#926) 2019-09-29 09:49:13 -07: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 run 10", () => {
    motors.largeB.run(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