CFC-Servers / GLuaTest

An exciting and nimble unit testing framework for GLua projects
https://discord.gg/epJK9Xx3pc
GNU General Public License v3.0
51 stars 2 forks source link

Add skip/when case keys #56

Closed brandonsturgeon closed 4 months ago

brandonsturgeon commented 4 months ago

This feature easily allows cases to be skipped, or only ran conditionally. For example, if your behavior is intended (or expected) to be different across JIT versions, you could do:

return {
    groupName = "isrunning action",
    cases = {
        {
            name = "Is not valid on 32bit versions",
            when = jit.version == "LuaJIT 2.0.4",
            func = function()
                expect( collectgarbage, "isrunning" ).to.errWith( [[bad argument #1 to '?' (invalid option 'isrunning')]] )
            end
        },

        {
            name = "Is valid on x86-64",
            when = jit.version == "LuaJIT 2.1.0-beta3",
            func = function()
                expect( collectgarbage, "isrunning" ).to.succeed()
                expect( collectgarbage( "isrunning" ) ).to.beA( "boolean" )
            end
        },
    }
}

This also adds a new classification of output at the end; SKIP image