Google-Apps
Hauptmenü

Post a Comment On: the urban canuk, eh

"My current approach to Context/Specification"

1 Comment -

1 – 1 of 1
Blogger David Tchepak said...

Hi Bryan,

I've recently started trying a similar approach. In terms of the because/context difference, I've found it helpful to use a sut creation method between context() and because(), which I got from JP's approach in the developwithpassion.bdd library.

My base context looks something like this:

[TestFixture]
public abstract class ConcernFor&ltT>
{
protected T sut;

[SetUp]
public void SetUp()
{
Context();
sut = CreateSubjectUnderTest();
Because();
}

protected virtual void Context() {}
protected abstract T CreateSubjectUnderTest();
protected virtual void Because() {}
}

This helps make the differentiation between context and because clearer: context sets up the dependencies and values needed for the rest of the concern, because calls the sut to start the scenario, and the test then asserts based on the effect of the sut's action.

Regards,
David

9:53 PM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.
Please prove you're not a robot