Variable captures
ii14 opened this issue · 0 comments
ii14 commented
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'