On 2011-12-29 06:11, Jonathan M Davis wrote:
On Wednesday, December 28, 2011 23:07:51 Jacob Carlborg wrote:
I think it is, don't know what others think. What it does is it catches
AssertErrors so other unit tests can continue to run and then gives a
nice report at the end.

I'm against it. I think that the compiler/runtime should be fixed so that each
unit test block is run in a module even if one fails. That would solve the
problem quite nicely IMHO, and that's already _supposed_ to be how it works.
It just isn't properly implemented in that regard yet. And I'm against
unittest blocks running any code after a single failure. So, I don't think
that any additional unit testing framework is necessary.

- Jonathan M Davis

Then the compiler need as well to collect all possible asserts and then somehow present them to the user. My library implementation already does this. Since this is completely implemented in library code it would be possible to have different formatters, a basic for outputting to the console and a more advanced with HTML output.

Less important but can be quite useful sometimes is that with my framework you add contexts to the unit tests, just like RSpec for those familiar with it.

If you haven't already, I suggest you take a look at the documentation for the unit test framework:

http://dl.dropbox.com/u/18386187/orange_docs/orange.test.UnitTester.html



For example:

import orange.test.UnitTester;

int sum (int x, int y)
{
    return x * y;
}

unittest ()
{
    describe("sum") in {
         it("should return the sum of the two given arguments") in {
              assert(sum(1, 2) == 3);
         }
    }
}

void main ()
{
    run;
}

If a test fails the framework will print out the context, the stack trace and a snippet from the failing test, something like this:

 sum
   - should return the sum of the given arguments

 Failures:
     1) sum should return the sum of the given arguments
        # main.d:44
        Stack trace:
        tango.core.Exception.AssertException@main(44): Assertion failure


 describe("sum") in {
        it("should return the sum of the given arguments") in {
                assert(sum(1, 2) == 3);
        };
 };

 1 test, 1 failure

--
/Jacob Carlborg

Reply via email to