Jump to content




Unittesting framework MineUnit

utility api

2 replies to this topic

#1 Helfull

  • New Members
  • 2 posts

Posted 28 October 2016 - 09:30 PM

Hey guys,

i have started to work on my UnitTesting framework for CC, since i couldn't find a framework here on the Forum.

Demo output
Posted Image
Posted Image


How to use:
Spoiler

Current Supported Assertions
Spoiler

MineUnit Options:
Spoiler

MineUnit Presenter Options:
Spoiler

ToDo:
  • Add more assertion methods
Any ideas for this are welcome

Download:
P0B9gDYh

Install:
pastebin get P0B9gDYh MineUnit

Demo code install:
pastebin get W8dAsfRY MineUnit

Edited by Helfull, 29 October 2016 - 12:22 AM.


#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 28 October 2016 - 11:33 PM

Psst - you forgot to post your code.

#3 Helfull

  • New Members
  • 2 posts

Posted 29 October 2016 - 12:10 AM

The moment i posted it, i had still to mich todo for a release ^^

but the passt 2 hours it got a all it needs

P0B9gDYh

also there are already changes to the demo code

os.loadAPI("MineUnit")

MineUnit.run({
    slowRuns = true, -- if you have many tests and want to see them all
    presenter = MineUnit.newPresenter({
        terminal = peripheral.wrap("left") -- choose your output term
    })
},
function(unit)

    unit:is(1, 1) -- Checks if 1 == 1
    unit:is(1, 2) -- Checks if 1 == 2

    unit:isEqual(1, 1) -- Alias for unit:is
    unit:isEqual(1, 2) -- Alias for unit:is

    unit:isTrue(true) -- checks if true == true
    unit:isTrue(false) -- checks if false == true

    unit:isFalse(false) -- checks if false == false
    unit:isFalse(true) -- checks if true == false

    unit:isSmaller(0, 1) -- checks if 0 < 1
    unit:isSmaller(1, 0) -- checks if 1 < 0

    unit:isGreater(1, 0) -- checks if 1 > 0
    unit:isGreater(0, 1) -- checks if 0 > 1

    unit:isSmallerOrEqual(1, 1) -- checks if 1 <= 1
    unit:isSmallerOrEqual(5, 1) -- checks if 5 <= 1

    unit:isGreaterOrEqual(2, 2) -- checks if 2 >= 2
    unit:isGreaterOrEqual(1, 5) -- checks if 1 >= 5

    local obj = {}
    unit:isType(obj, "table") -- Checks if type(obj) == "table"
    unit:isType(obj, "function") -- Checks if type(obj) == "function"

    local function test(v1, v2, v3)
        return (v1 == v2) and (v1 == v3)
    end
    unit:shouldReturn(test, true) -- Checks the return value of test against true
    unit:shouldReturn(test, false) -- Checks the return value of test against false

end)

support for monitor output
Posted Image





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users