What I've been working on

1 view
Skip to first unread message

Jason Diamond

unread,
Sep 12, 2009, 7:13:50 PM9/12/09
to beh...@googlegroups.com
Hi guys,

I've been working on some changes to BehaveN and wanted to type them
out to see if anybody had any input.

1. I'm trying to make the [Given], [When], and [Then] attributes
optional and might even remove them.

At my work, we still love the text syntax. Since we don't get
IntelliSense, we have to open up the classes that contain our step
definitions and look for what we can use. Yeah, this part kinda sucks,
but we're OK with it. What bothers us, though, is how difficult it is
to find a given, when, or then since none of the methods are prefixed
with those keywords.

So we started prefixing our methods to make them easier to find (as
suggested by Cliff even though he wanted it for the code syntax). That
helps because it groups all of our methods together in the navigation
bar or ReSharper Go To Member command, but now the attributes seem
redundant:

[Given]
public void given_a_new_foo()
{
}

I realized I could just use the convention of "if the method name
starts with given, then, or when, it's probably a step definition".

The only problem with this is that we use the attributes to specify
our regular expression patterns. Then I realized I could infer that,
too:

public void given_a_new_foo_with_bar_and_baz(int bar, decimal baz)
{
}

Because there are parameter names that match parts of the method name,
I'm able to infer a usable regular expression. I've added support for
ints, decimals, strings, and enumerations so far. That's the majority
of the parameter types we use (that aren't converted from forms or
grids).

This is working out really well although we haven't converted
everything over yet (we have a lot of step definitions).

If you're using the code syntax, this doesn't affect you at all since
you didn't even need the attributes to begin with.

On a related note, Ranjit mentioned that he likes this syntax:

scenario.Given(a_new_foo);

Cliff mentioned that he likes this syntax:

scenario.Add(given_a_new_foo);

I don't see anything wrong with continuing to support both styles for
the code syntax.

2. Undefined and pending steps now cause the test to fail.

I think it's wrong that incomplete tests get marked as passed by your
test runner. This shouldn't be too controversial.

3. Switched to Git.

I'm *loving* Git. You can find my development branch on GitHub here:

http://github.com/jdiamond/behaven/tree/dev

There's also a master branch that I plan on keeping in sync with
Subversion. What I think I'll do is keep working on my dev branch
until I want to make a release. Then merge that into master. Then
commit master to SVN.

If you want to track my development, you can clone the repository and
pull from my dev branch. If you want to contribute, fork the
repository on GitHub (you'll have to make an account), push your
changes to your forked repo, and then send me a pull request.

You can find some guides on GitHub. I also highly recommend this online book:

http://progit.org/

That's it for now. See ya.

--
Jason

Reply all
Reply to author
Forward
0 new messages