Uberto Barbini wrote:
> JS> I like dunit ... but I like Nunit a whole lot more. Seriously nice the
> I've used Nunit only when it was very rough (.NET beta 2).
> Apart from .NET features (attributes, introspection, etc.) do you
> think the design of Dunit can "borrow" something from Nunit?
I don't know what version you were using then, but they did a pretty
comprehensive redesign for Nunit 2. Nunit 1 was pretty much a Junit
port and thus, I assume, much like Dunit. In Nunit 2, they use
[TestFixture] and [Test] attributes: any public class with
[TestFixture] attribute and a public parameter-less constructor can
hold tests. Any public void parameter-less procedure, with a [Test]
attribute, in a [TestFixture] class is a test. No need for magic names
or inheritance from special classes.
You compile and run your executable with tests in it, and test it that
way. The Nunit test harness uses reflection to find all the [Test]
functions in [TestFixture] classes and run them. It picks up on
changes automatically; if you compile new tests into the exexcutable,
the test tree in the GUI version reflects it before you even re-run
It's all quite slick (although the GUI is sorta clunky) but I don't
know what Dunit can borrow from unless/until attributes make their way
into the Classic Delphis. Even then, Delphi's smart linking may bollox
> I like to have unit tests separated from "real exe", but I'd like to
> test my exe too (functionality tests).
> Can you explain better?
With Dunit, I always end up with a unit that has actual code, and a
unit that contains the tests, which is slightly cumbersome. I also
have to build two independent projects (albeit they can live in the
same project group) and toggle between running the actual program and
running the test suite.
With Nunit, the [Test] functions live in the class they test, which
makes it possible to test private and protected features. (Yes, it's
the public features that matter, but being able to test the private
and protected features as you build functionality is very nice.)
With Nunit, the test harness stays up all day long, and refreshes
itself every time I recompile. I can run the executable from VS, or
Alt+Tab to the test harness to run the tests. (I do that about just
about every time I compile.)
Consulting & contract programming http://www.midnightbeach.com
My Kylix book http://www.midnightbeach.com/kylix
Homeschool resources http://www.midnightbeach.com/hs