The error message for a failing expect call doesn't provide a lot of context about which line is failing. For example, # Expected 2 to equal '1' if there are several expect calls in the test, all of which involve numbers, or perhaps when checking a property of a list of items in a loop.
Describe the solution you'd like
I'd like to specify a message as part of the expect chain, much as one can be provided with assert calls. I can think of a couple ways this could be done:
Optional parameter: s:expect(len(l:mylist), 'should have one element').to_equal(1)
Chained function calls: s:expect(len(l:mylist)).with_message('should have one element').to_equal(1)
Provide message as a context:
let s:withmsg = themis#helper('with_message')
call s:withmsg('should have one element').expect(len(l:mylist)).to_equal(1)
" could wrap assert, too
call s:withmsg('should be upper case').assert.match(l:mylist[0], '^[A-Z]\+l')
Is your feature request related to a problem?
The error message for a failing
expect
call doesn't provide a lot of context about which line is failing. For example,# Expected 2 to equal '1'
if there are severalexpect
calls in the test, all of which involve numbers, or perhaps when checking a property of a list of items in a loop.Describe the solution you'd like
I'd like to specify a message as part of the
expect
chain, much as one can be provided withassert
calls. I can think of a couple ways this could be done:s:expect(len(l:mylist), 'should have one element').to_equal(1)
s:expect(len(l:mylist)).with_message('should have one element').to_equal(1)