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

Variable captures #679

Open
ii14 opened this issue May 21, 2022 · 0 comments
Open

Variable captures #679

ii14 opened this issue May 21, 2022 · 0 comments

Comments

@ii14
Copy link

ii14 commented May 21, 2022

An alternative solution to #589 is to have a way of capturing variables that can be printed on assertion failures, to give them more context.

describe('foo', function()
  it('does something', function()
    for k, v in pairs({
      foo = 'foo',
      bar = 'foo',
    }) do
      capture.key = k
      assert.is_equal(k, v)
    end
  end)
end)

capture could be just a normal table that is reset before every test.
And then on a failed assertion the table could be printed:

foo.lua:8: Expected objects to be equal.
Captures:
key = (string) 'bar'
Passed in:
(string) 'foo'
Expected:
(string) 'bar'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant