Let's bikeshed std.experimental.testing assertions/checks/whatchamacallits
linkrope via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jul 3 07:07:45 PDT 2015
1. 'assert' is the wrong thing
I do not need a stack trace for a failed expectation in a unit
test.
But, usually, I need a stack trace for a contract violation from
deep down in the unit under test:
https://github.com/linkrope/dunit#failures-vs-errors
Consequently, the failed expectation should throw some "failed
expectation" 'Exception' instead of an 'AssertError'. So,
std.exception.assertThrown cannot be used for expectations.
2. something like an 'assert' with better diagnostics could be
nice
Catch for C++ introduced 'REQUIRE' with helpful failure messages:
Example.cpp:9: FAILED:
REQUIRE( Factorial(0) == 1 )
with expansion:
0 == 1
https://github.com/philsquared/Catch
3. 'should' seems to be obsolete
Now, 'expect' should be used for expectations:
http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
More information about the Digitalmars-d
mailing list