Re: DUnit: Advanced unit testing toolkit.

2013-09-22 Thread linkrope

Have a look at https://github.com/linkrope/dunit, especially at
the Related Projects.

Until now, my preferred tool for (large-scale) unit testing in D
would be the combination of my dunit framework (of course),
DMocks-revived for mocks, and the 'must' matchers of specd.

How does your toolkit fit in?


Re: DUnit: Advanced unit testing toolkit.

2013-09-22 Thread Gary Willoughby

On Sunday, 22 September 2013 at 13:13:29 UTC, linkrope wrote:

Have a look at https://github.com/linkrope/dunit, especially at
the Related Projects.

Until now, my preferred tool for (large-scale) unit testing in D
would be the combination of my dunit framework (of course),
DMocks-revived for mocks, and the 'must' matchers of specd.

How does your toolkit fit in?


I looked at DMocks and Specd before i started work on DUnit to 
see what was out there. I'm not saying that DUnit does anything 
really different than those two combined but i'm trying to make 
it simpler to use and more intuitive.


For example DMocks uses an intermediary object to handle the 
mocks. This is thought was a bit strange as this behaviour should 
be in the mock to begin with. So my first objective was to 
provide a way of very simply creating a mock object and to 
interact with that mock object directly. This also fulfilled the 
secondary objective of moving 'setup' code out of the unit test 
and making them more easy to read. Also DUnit solved the problem 
that Dmocks doesn't address of correctly handling Object base 
class methods properly. All methods can fall-through to parent 
implementations or be replaced at runtime.


Specd is a nice approach to defining constraints but again it 
seems overkill for something that should be simple. I don't do 
anything different, i just do it in a different way.


specd: 1.must.be.greater_than(0);
dunit: 1.assertGreaterThan(0);

The reason i've gone with just providing more specific assert 
methods is that i can create nice helpful error message when 
things go wrong. For example this line:


1.assertEquals(0);

Creates this error:

+
| Failed asserting equal
+
| File: example.d
| Line: 85
+
| ✓ Expected int: 1
| ✗ Actual int: 2

Making debugging what went wrong loads easier. These messages 
give you so much useful info that you will never go back to only 
using assert() again.


Re: DUnit: Advanced unit testing toolkit.

2013-09-22 Thread Gary Willoughby
On Sunday, 22 September 2013 at 15:54:39 UTC, Gary Willoughby 
wrote:
The reason i've gone with just providing more specific assert 
methods is that i can create nice helpful error message when 
things go wrong. For example this line:


1.assertEquals(0);

Creates this error:


+

| Failed asserting equal

+

| File: example.d
| Line: 85

+

| ✓ Expected int: 1
| ✗ Actual int: 2

Making debugging what went wrong loads easier. These messages 
give you so much useful info that you will never go back to 
only using assert() again.


Actually that should read:

+
| Failed asserting equal
+
| File: example.d
| Line: 85
+
| ✓ Expected int: 0
| ✗ Actual int: 1

But you get the idea. ;)


Re: DUnit: Advanced unit testing toolkit.

2013-09-22 Thread Jacob Carlborg

On 2013-09-21 02:40, Gary Willoughby wrote:

DUnit: Advanced unit testing toolkit.

I've needed this for a project i've been working on so i created a
toolkit that i'm using and happy with. I must thank the community here
for helping me with a few issues along the way (mostly due to poor
documentation). It uses a lot of compile time reflection to generate the
mocks, which has been very interesting to learn/write (to say the least).

I think it's useful enough now to release and it would be nice to
perhaps receive some guidance as to where it should improve or fails
spectacularly.

Wikipedia: http://en.wikipedia.org/wiki/Unit_testing

DUnit: https://github.com/kalekold/dunit

See examples and documentation for usage.

Have fun.


You might want to use alternatively you could use version(unittest) 
instead of debug for the mocks. Don't know which is better.


--
/Jacob Carlborg