assert complicated_func("myinput") == "myoutput"
and when I run testament over it I see
.../fatal.nim(49) sysFatal
Error: unhandled exception: /home/me/awsome/test_complicated.nim (14, 8) `complicated_func("myinput") == "myoutput"` [AssertionDefect]
So I know complicated_func("myinput") does not return "myoutput", but it would be even more helpful to see what value complicated_func("myinput") did return.
Any way to get the values on both sides of the assert statement printed during the test run?
I dont know about testament, but assert can take a message so you can do:
let a = 100
assert $a == "myoutput", "a was " & $a
Well the trick is to use a template as follows, which lets you easily pass two values and it'll handle the comparison/write the values in a string.
import strformat
template assertCompare(a, b: untyped) =
assert a == b, "`a` was " & $a & " `b` was " & $b
assertCompare(10, 11)
that's fine, Nim repo uses a lot of unittest.check in tests running with testament. https://github.com/nim-lang/Nim/blob/47c078e29c7e459e8b413dcc0020637e6e042c44/tests/stdlib/ttimes.nim#L472
only unittest.suite and unittest.test are not recommended to use. https://nim-lang.github.io/Nim/contributing.html#writing-tests-stdlib