Log In  

Cart #tinytest-0 | 2023-09-09 | Code ▽ | Embed ▽ | No License
2


This is the tinytest library for pico-8; it was inspired by the tinytest javascript library by Joe Walnes. It provides a basic unit test framework.

You can use it one of two ways: as a no frills library or as a singing, dancing cart.

Library Usage

You will enjoy colored text reports but otherwise no frills, but it's very flexible this way.

#include tinytest.p8

tinytest:new():run({
  demo_pass = function(t)
    t:ok(true, "hi")
  end,

  demo_fail = function(t)
    t:ok(false, "bye")
  end,

  demo_error = function(t)
    assert(false, "wtf")
  end,

  demo_misc  =
  function(t)
    t:ok(false, "bye2")
    assert(false, "wtf2")
  end,
})

Cart Usage

The cart comes with some images of bob from the incredibles in meme format and some audio sfx so you can hear the sweet sound of tests passing, failing, and erroring to make unit testing more fun.

In your cart, define my_tinytests:

-- yourcart.p8
my_tinytests = {
  demo_pass = function(t)
    t:ok(true, "yep")
  end
}

Edit tinytest.p8's cart:

-- tinytest.p8
#include yourcart.p8

Load tinytest.p8 and on every run it will exercise your tests. Since it does an include, you don't have to reload either.

TODO

  • Add more bob meme images (only two currently)

License

Copyright (c) 2023 Shane Celis
Licensed under the MIT License

P#134089 2023-09-09 12:00 ( Edited 2023-09-10 05:50)


[Please log in to post a comment]