This will let each test case define its own setup/cleanup functions, and give entire test files the ability to run setup/cleanup before/after each or all of its test cases.
Test file could now look like:
(The before/after and setup/cleanup funcs would be optional of course)
return {
beforeAll = function() end,
beforeEach = function( state ) state.ent = ents.Create( "blah" ) end,
afterAll = function() end,
afterEach = function( state ) if IsValid( state.ent ) then state.ent:Remove() end end,
cases = {
{
name = "Example test",
setup = function( state ) state.ent:SetMaterial( "pp/whatever" ) end,
cleanup = function( state ) print( state.ent ) end,
func = function( state )
expect( state.ent:GetMaterial() ).to.equal( "pp/whatever" )
end
}
}
}
This will let each test case define its own setup/cleanup functions, and give entire test files the ability to run setup/cleanup before/after each or all of its test cases.
Test file could now look like: (The before/after and setup/cleanup funcs would be optional of course)