All 6 entries tagged Bdd

No other Warwick Blogs use the tag Bdd on entries | View entries tagged Bdd at Technorati | There are no images tagged Bdd on this blog

June 27, 2006

Rhino Mocks Boo Macros Released

Writing about web page

My Boo syntactic macros for the Rhino Mocks mock object library are available to test. I've only spent a few days working on them but they are already powerful.

For download links and docs see preliminary documentation

June 12, 2006

BDD Meta–programming

I'm working on a Boo macro library for Rhino Mocks . I'm "dog-fooding" my Specter behaviour driven development framework in the process.
I have to be able to specify how a macro should expand into real code. The spec code is now looking like this:
specify "x as int arg is sent as 0":
ast { disallow foo.Bar(x as int) },
ast { foo.Bar(0); Rhino.Mocks.LastCall.Repeat.Never() }

I'm loving how flexible the Boo language is. It's hard to believe that the code is still Boo!

"check" is a function that expands the first argument using the macro being spec'd and makes sure it matches the second argument. (check is actual a partial application of a general check function that takes the macro first)

check = { input as MacroStatement, expected as Node | CheckMacro(macro, input, expected) }
def CheckMacro(macro as AbstractAstMacro, input as MacroStatement, expected as Node):
m = Method()

May 04, 2006


specter logo

May 02, 2006


I'm waiting for SourceForge to approve my Specter project (previously know as BooSpec). It's been 7 days so far already.. I'm hoping they're just really busy and will get round to me soon.
I'll blog as soon as the project is approved (fingers crossed!). Anyone who wants to collaborate will then be welcome to join the project.

I had another syntax idea today as well…

Instead of something like:

how about:
foo.Must.Be <= 42

I can make the object returned by "Be" overload the comparison operators. This makes for much less typing and I think is easier to read. Of course, I can support both forms in Specter and let the user decide which they prefer.

Similarly the equality specifications become:

foo.Must.Be == 42
Actually, now that I think about it… I can probably make the Boo macro look for statements that are just binary expressions (A op B) and output correct method calls at compile time. This would make for specs like this:
context "Sample spec":
x as int

x < 42
:D This could be awesome!

April 18, 2006


Follow-up to Behavior Driven Development: BooSpec from codeMonkey.Weblog();

Wooo! I thought it couldn't be done, but Boo's syntactic macros (given an afternoon of hacking!) allow me to do this:
import BooSpec

context TestContext:
data as string

data = "hello"

specify Print:
print data

e = TestContext()
Yup, that's right! The "context" macro is creating a new class. The setup and specify macros create methods. Basically what this means is soon we'll be able to write object behaviour specifications without all that nasty non-spec syntax getting in the way.
class EmptyStack:
def CountIsZero():
with simply:
context "Empty Stack"
specify "Count is zero":
I must say a huge thank you to the guys over on the BooLang group. Without their advice and examples I'd never have gotten here!

April 16, 2006

Behavior Driven Development: BooSpec

This weekend is watched this video I then spent a lot of time exploring a relatively new concept in the agile development world: Behavior Driven Development (BDD).

RSpec is a Ruby project to allow creation of runnable specifications. There is a related project for .NET called NSpec

I have also been exploring Boo , a cool new language targeting .NET. Whilst NSpec allows the creation of runnable specs, I don't like the slightly clunky syntax imposed by C#. I want my spec to be as human readable as possible. Basically we need extension methods in C#. These are coming in 3.0, but for now I thought I'd look at Boo. Boo allows me to more closely approximate RSpec's Ruby syntax, giving rise to Boo specs like this:

namespace Test

import BooSpec

class EmptyStack:
private stack as Stack

def SetUp():
stack = Stack(10)

def CountIsZero():

def PopThrowsException():
{ stack.Pop() }.Must().Throw(typeof(IllegalOperationException))

def PushedItemIsOnTop():

I especially like "{ stack.Pop() }.Must().Throw(typeof(IllegalOperationException))". It's just so succinct!

I'm tempted to start a new project called "BooSpec". This would be a library similar to RSpec and NSpec, but written in Boo. The BooSpec library could be used by any .NET language, except the Must() extension methods calls would have to revert to normal static calls. Of course there is nothing wrong with writing the spec in Boo and the application code in C# or VB.NET!

Google Ads

Search this blog

Most recent comments

  • I scratched my eye while i was holding some kind of plastic packaging.. Anyways the corner of the pl… by Ercan on this entry
  • About a year ago my contacts that i was wearing, i guess were fautly, because shortly after they wer… by Jon on this entry
  • I got shower gel in my eye 4 and a half days ago, and becasue i rubbed my eyes a lot, i have scratch… by Chris on this entry
  • This website may help–health/tc/Eye–Injuries–Home–Treatment by S on this entry
  • I somehow got dirt, or debris in my eye. The terrible pain sent me in a tailspin. I was afraid of sa… by Bobbi on this entry


September 2021

Mo Tu We Th Fr Sa Su
Aug |  Today  |
      1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30         


Blog archive

RSS2.0 Atom
Not signed in
Sign in

Powered by BlogBuilder