Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fail() function #57

Merged
merged 2 commits into from
Apr 3, 2024
Merged

Add fail() function #57

merged 2 commits into from
Apr 3, 2024

Conversation

brandonsturgeon
Copy link
Member

@brandonsturgeon brandonsturgeon commented Apr 3, 2024

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 brandonsturgeon self-assigned this Apr 3, 2024
@@ -270,6 +278,7 @@ return function( allTestGroups )
for id, case in pairs( asyncCases ) do
if callbacks[id] == nil then
setTimedOut( case )
callbacks[case.id] = false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the independent bugfix (that I should probably merge separately...)

@brandonsturgeon
Copy link
Member Author

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

@brandonsturgeon brandonsturgeon merged commit 0bf7738 into main Apr 3, 2024
1 check passed
@brandonsturgeon brandonsturgeon deleted the feature/add-fail-method branch April 3, 2024 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant