lunarmodules / busted

Elegant Lua unit testing.
https://lunarmodules.github.io/busted/
MIT License
1.4k stars 185 forks source link

How to run busted in ios with multiple unit_test file #612

Open gopep9 opened 5 years ago

gopep9 commented 5 years ago

I want to use busted in ios lua project. Now I can run busted like this

--unitTest.lua
require 'busted.runner'()
describe("Busted unit testing framework", function()
    -- body
    describe("should be awesome", function()
        it("should be easy to use", function()
            print(package.path)
            assert.truthy("Yup.")
        end)
    end)
end)
--main.lua
require("unitTest")

but it seem like the unit test code must be write in the one lua file. is it any way to write unit test code in multiple lua file and run them?

gopep9 commented 5 years ago

I find a way to do this by string concatenation,just like this

total_str = ""

local file = io.open("a.lua","r")
a_str = file:read("*a")
file:close()
total_str = total_str..a_str

file = io.open("b.lua","r")
b_str = file:read("*a")
file:close()
total_str = total_str..b_str

load(total_str)()
ildar commented 5 years ago

Just a bunch of bare ideas: a kind of RPC or debug could help, though I'm not sure. E.g. MobDebug (+ZBS), LuaRPC/Tango,...

EricFedrowisch commented 4 years ago

Here's one way I found: https://github.com/Olivine-Labs/busted/issues/571