digitalmars.D - Failed unittest
- monarch_dodra (22/22) Aug 20 2012 I find unittests to be a very very useful too in D. However, one
- Jacob Carlborg (7/25) Aug 20 2012 The intention is that the unit tests will be changed so it continues
- Robik (22/30) Aug 20 2012 Yes.
I find unittests to be a very very useful too in D. However, one of the things that I am seeing is that it does not scale very well (Phobos in mind), as the tests stop as soon as the first failure. Heck compilation stops at the first unittest compilation failure. This is bad because: a) In a large scale project, there are always some things that are broken b) There is no way to pre-emptivelly write a "failing" unit test, while waiting for a known bug to be fixed. The end result are tests that are not as aggressive as they could be, or things that are not covered, because they did not initially work due to some bug somewhere else, and nobody writing the test once said bug was solved... I'm wondering if: 1) Would it be possible to compile "as many unittests as possible", and simply omit the tests that static assert? This would create a "unit test compilation failure", but not prevent the tests that *did* compile from moving on to the run-time testing. 2) Would it be possible to execute ALL unit tests, even after one fails?
Aug 20 2012
On 2012-08-20 11:51, monarch_dodra wrote:I find unittests to be a very very useful too in D. However, one of the things that I am seeing is that it does not scale very well (Phobos in mind), as the tests stop as soon as the first failure. Heck compilation stops at the first unittest compilation failure. This is bad because: a) In a large scale project, there are always some things that are broken b) There is no way to pre-emptivelly write a "failing" unit test, while waiting for a known bug to be fixed. The end result are tests that are not as aggressive as they could be, or things that are not covered, because they did not initially work due to some bug somewhere else, and nobody writing the test once said bug was solved... I'm wondering if: 1) Would it be possible to compile "as many unittests as possible", and simply omit the tests that static assert? This would create a "unit test compilation failure", but not prevent the tests that *did* compile from moving on to the run-time testing. 2) Would it be possible to execute ALL unit tests, even after one fails?The intention is that the unit tests will be changed so it continues after a failed unit test. This is either per module or per unit test block. A temporary solution is to implement a library solution. For example: https://github.com/jacob-carlborg/orange/blob/master/orange/test/UnitTester.d -- /Jacob Carlborg
Aug 20 2012
On Monday, 20 August 2012 at 09:51:10 UTC, monarch_dodra wrote:I'm wondering if: 1) Would it be possible to compile "as many unittests as possible", and simply omit the tests that static assert? This would create a "unit test compilation failure", but not prevent the tests that *did* compile from moving on to the run-time testing. 2) Would it be possible to execute ALL unit tests, even after one fails?Yes. You can set assertHandler to your own function. Something like: import core.exception, std.stdio; void handler(string file, ulong line, string msg) { if(msg == null) { writefln("-- %s(%d)", file, line); } else { writefln("-- %s(%d): %s", file, line, msg); } } void main(){} unittest { setAssertHandler(&handler); assert(1==2); assert(1==3, "1 is not equal to 3"); } More info can be found here: http://dlang.org/phobos/core_exception.html
Aug 20 2012