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 fail() function #57

Closed brandonsturgeon closed 4 months ago

brandonsturgeon commented 4 months ago

This is a compliment to the done() function, except it fails the test case.

This is useful for situations where you want to fail a test case if a callback is called. For example, if you were going to test http.Fetch:

{
    name = "http.Fetch doesn't fail",
    async = true,
    timeout = 3,
    func = function()
        http.Fetch( "url", function( body ) expect( #body ).to.equal( 1024 ) end, fail )
    end
}

Without the fail function, you would need to intentionally throw an error or fail an expectation inside the failure callback (and wait for the timeout to actually finish the test).

(This also fixes an issue where test groups would stop running if the per-group timeout was hit)

brandonsturgeon commented 4 months ago

Decided to include the timeout bugfix in here, but it will actually be refactored away in a followup PR