Posted 28 October 2016 - 10: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
How to use:
Current Supported Assertions
MineUnit Options:
MineUnit Presenter Options:
ToDo:
Download:
P0B9gDYh
Install:
Demo code install:
i have started to work on my UnitTesting framework for CC, since i couldn't find a framework here on the Forum.
Demo output
How to use:
Spoiler
os.loadAPI("MineUnit")
MineUnit.run({
slowRuns = true,
presenter = MineUnit.newPresenter({
terminal = peripheral.wrap("left")
})
},
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)
Current Supported Assertions
Spoiler
unit:is
unit:isEqual
unit:isTrue
unit:isFalse
unit:isSmaller
unit:isGreater
unit:isSmallerOrEqual
unit:isGreaterOrEqual
unit:isType
unit:shouldReturn
MineUnit Options:
Spoiler
{
presenter = Presenter:new(), -- the presenter to use
slowRuns = false, -- should it run the tests slow
}
MineUnit Presenter Options:
Spoiler
{
terminal = term, -- your terminal/monitor you want to use for the output
fullMessages = true, -- should it show the full assertion text or only dots for success and "X" for failures
failedTextColor = FailureTextColor, -- what text color should failures have
failedBackgroundColor = FailureBackgroundColor, -- what background color should failures have
successTextColor = SuccessTextColor, -- what text color should successfull assertions have
successBackgroundColor = SuccessBackgroundColor, -- what background color should successfull assertions have
errorTextColor = ErrorTextColor, -- what text color should errors have
errorBackgroundColor = ErrorBackgroundColor -- what background color should errors have
}
ToDo:
- Add more assertion methods
Download:
P0B9gDYh
Install:
pastebin get P0B9gDYh MineUnit
Demo code install:
pastebin get W8dAsfRY MineUnit
Edited on 28 October 2016 - 11:22 PM