xUnit Testing Framework for D

Mario Kroeplin linkrope at github.com
Sun Jun 16 12:48:39 PDT 2013


On Thursday, 13 June 2013 at 00:10:56 UTC, bearophile wrote:
> In that code have you felt the lack for some built-in feature 
> for D (Like some introspection, some hooks, some dynamic 
> feature, etc)?

D(1)Unit has a 'fixturebuilder' that iterates over 'ModuleInfo' 
and 'localClasses', and finally follows 'base' links to discover 
the test classes that have to be derived from 'TestFixture'.

For d(2)unit, Juan Manuel Cabo didn't use all this introspection. 
With the 'mixin', the single inheritance must no longer be spent 
for the testing framework. '__traits(allMembers' and 
'__traits(compiles' are good enough support for the compile-time 
discovery of the tests.

User-Defined Attributes were great to get rid of the required 
naming of the member functions. But here I would wish for more. 
As far as I understand:

1. I cannot have both '@Ignore' and '@Ignore("some reason")'
2. I cannot have the 'mixin' implied by attaching '@UnitTest' to 
a test class

> Maybe you can replace code like this:
>
> final switch (color)
>             {
>                 case Color.red:
>
>
> With code like:
>
> final switch (color) with (Color)
>             {
>                 case red:

Done. Shame on me: AnalyzeD has the style warning "prefer with 
for switch statements".
(What's the source of this guideline?)

I dislike this guideline when used together with "put braces 
around all statements, even single statements". Either you need 
an exception to the rule or you have to write less attractive 
code with 'switch' and 'with' on separate lines with an extra 
indentation level.



More information about the Digitalmars-d-announce mailing list