Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yagocrispim/moontest
Single file test utility without dependencies
https://github.com/yagocrispim/moontest
Last synced: about 2 months ago
JSON representation
Single file test utility without dependencies
- Host: GitHub
- URL: https://github.com/yagocrispim/moontest
- Owner: YagoCrispim
- Created: 2024-08-18T22:22:40.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-18T22:43:33.000Z (5 months ago)
- Last Synced: 2024-08-18T23:31:37.985Z (5 months ago)
- Language: Lua
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# moontest
Single file test utility without dependencies## Example
```lua
local mt = require "moontest"local function Person(name, age)
local _name = name
local _age = agereturn {
set_data = function(_, data)
_name = data.name
_age = data.age
end,get_data = function()
--
return {name = _name, age = _age}
end
}
end-- test context
local tc = {person = nil}mt.describe("Person", {
-- before_all = function() print("Before all") end,
-- after_all = function() print("After all") end,
before_each = function()
--
tc.person = Person("John", 21)
end,
-- after_each = function() print("After each") end,
--
mt.it("should return name and age", function()
local data = tc.person:get_data()
return {data.name == "John", data.age == 21}
end), --
--
mt.it("should set data", function()
tc.person:set_data({name = "John 2", age = 200})
local data = tc.person:get_data()
return {data.name == "John 2", data.age == 200}
end) --
})
```## WIP docs