digitalmars.D.announce - specd - write more expressive unit tests
- jostly (17/17) Sep 02 2013 specd is a DSL library allowing you to write more expressive unit
- Jacob Carlborg (7/21) Sep 02 2013 I've been working on something similar myself.
- jostly (6/33) Sep 04 2013 Narrowly avoided nameclash there. :) Good to see others thinking
- Jacob Carlborg (5/7) Sep 04 2013 Very simple but very powerful. It's basically way to tag symbols with
- linkrope (14/14) Sep 04 2013 It would be nice to have something like
- jostly (3/17) Sep 04 2013 Thanks for the feedback and the pointers - I think they're all
specd is a DSL library allowing you to write more expressive unit
tests. It is inspired by projects like specs2 and ScalaTest from
the Scala world.
Example:
unittest {
describe("a string")
.should("have a length property",
"foo".length.must.equal(3));
}
Features:
* DSL for expressing unit tests as specifications
* Verify with "must" instead of assert
* Report successful / failed tests using green / red paradigm
Available as a dub dependency ("specd") or from
https://github.com/jostly/specd
Comments and suggestions for improvement are welcome!
//Johan
Sep 02 2013
On 2013-09-02 21:03, jostly wrote:
specd is a DSL library allowing you to write more expressive unit tests.
It is inspired by projects like specs2 and ScalaTest from the Scala world.
Example:
unittest {
describe("a string")
.should("have a length property", "foo".length.must.equal(3));
}
Features:
* DSL for expressing unit tests as specifications
* Verify with "must" instead of assert
* Report successful / failed tests using green / red paradigm
Available as a dub dependency ("specd") or from
https://github.com/jostly/specd
Comments and suggestions for improvement are welcome!
I've been working on something similar myself.
https://github.com/jacob-carlborg/dspec
I'm working on a new syntax using UDA's, shown here:
https://github.com/jacob-carlborg/phobos/blob/serialization/std/serialization/tests/array.d
--
/Jacob Carlborg
Sep 02 2013
On Tuesday, 3 September 2013 at 06:36:20 UTC, Jacob Carlborg wrote:On 2013-09-02 21:03, jostly wrote:Narrowly avoided nameclash there. :) Good to see others thinking along the same lines.specd is a DSL library allowing you to write more expressive unit tests. It is inspired by projects like specs2 and ScalaTest from the Scala world. Example: unittest { describe("a string") .should("have a length property", "foo".length.must.equal(3)); } Features: * DSL for expressing unit tests as specifications * Verify with "must" instead of assert * Report successful / failed tests using green / red paradigm Available as a dub dependency ("specd") or from https://github.com/jostly/specd Comments and suggestions for improvement are welcome!I've been working on something similar myself. https://github.com/jacob-carlborg/dspecI'm working on a new syntax using UDA's, shown here: https://github.com/jacob-carlborg/phobos/blob/serialization/std/serialization/tests/array.dLooks interesting. I hadn't heard of the UDA's before, they seem quite powerful from a brief glance.
Sep 04 2013
On 2013-09-04 19:38, jostly wrote:Looks interesting. I hadn't heard of the UDA's before, they seem quite powerful from a brief glance.Very simple but very powerful. It's basically way to tag symbols with values/types. -- /Jacob Carlborg
Sep 04 2013
It would be nice to have something like
result.must.not.be!">"(42);
So, have a look at 'assertOp':
http://d.puremagic.com/issues/show_bug.cgi?id=4653
How can a user of your code add matchers, for example, to check
for elements or attributes in XML? (Without having to change your
code.) The hidden 'MatchStatement' makes the code easy to use but
seems to make it hard to extend. You could add a second
('matcher') parameter to 'must', but then you have to switch from
'.' to '('...')':
result.must(haveTag("root"));
By the way: Does the color output work on Windows?
Here is what I do to color the unit-test results:
https://github.com/linkrope/dunit/blob/master/dunit/color.d
Sep 04 2013
On Wednesday, 4 September 2013 at 11:06:45 UTC, linkrope wrote:
It would be nice to have something like
result.must.not.be!">"(42);
So, have a look at 'assertOp':
http://d.puremagic.com/issues/show_bug.cgi?id=4653
How can a user of your code add matchers, for example, to check
for elements or attributes in XML? (Without having to change
your code.) The hidden 'MatchStatement' makes the code easy to
use but seems to make it hard to extend. You could add a second
('matcher') parameter to 'must', but then you have to switch
from '.' to '('...')':
result.must(haveTag("root"));
By the way: Does the color output work on Windows?
Here is what I do to color the unit-test results:
https://github.com/linkrope/dunit/blob/master/dunit/color.d
Thanks for the feedback and the pointers - I think they're all
good ideas. I'll look into making the necessary adjustments.
Sep 04 2013









Jacob Carlborg <doob me.com> 