This project is read-only.

Multiple contexts per class?

Apr 21, 2009 at 8:16 PM
I am grooving on this framework. Nice job, guys. I do have a thought/concern/question.

When adding multiple scenarios, it is common for the scenarios to differ in context. In that case I am a bit loath to declare multiple scenarios per story in the same test. So, I tried sharing the sotry as a class member and one context per test method. Trying various ways of organizing my tests so they dont get HUGE.

How do you arrange things? Do you have test code you could share?

Coordinator
May 3, 2009 at 10:04 AM
daddystarr,

Sorry about the delay. I'm just back from holiday and haven't been near a computer. I think this might be the best answer is an adaptation on Example Four on the home page (http://storyq.codeplex.com/#examplethree).
.WithScenario("Writing specifications again")
                    .Given(() => ThatEverythingIsnt())
                    .When(() => TheTestIs_("run"))
                    .Then("the test result should be pending");
        static void TheTestIs_(string s)
        {
            Assert.AreEqual(s, "run");
        }


If you have differences based on context then you should add those differences as parameters and then where they need to be displayed add an underscore in the name of the method.
Note: you can add as many underscores as you wish but should have the same number of parameters.

Also, if you need it to be more DRY. Remember that strings can be replaced with Narrative.Text and Narrative.Execute.

Something to also check, are you trying to write these BDD-style of RSpec? I suspect so. If so, think about actually using RSpec on IronRuby! MMmmmmm. That's where I am heading.

I am still using storyq for acceptance tests and find that I don't need much that what is currently available. So, feel free to post examples and we can think about coding solutions.

Cheers todd

May 4, 2009 at 4:30 PM
This makes sense.

I will try it. Thank you.

David Starr
elegantcode.com | pluralsight.com



On Sun, May 3, 2009 at 3:04 AM, toddb <notifications@codeplex.com> wrote:

From: toddb

daddystarr,

Sorry about the delay. I'm just back from holiday and haven't been near a computer. I think this might be the best answer is an adaptation on Example Four on the home page (http://storyq.codeplex.com/#examplethree).
.WithScenario("Writing specifications again")
                    .Given(() => ThatEverythingIsnt())
                    .When(() => TheTestIs_("run"))
                    .Then("the test result should be pending");
        static void TheTestIs_(string s)
        {
            Assert.AreEqual(s, "run");
        }


If you have differences based on context then you should add those differences as parameters and then where they need to be displayed add an underscore in the name of the method.
Note: you can add as many underscores as you wish but should have the same number of parameters.

Also, if you need it to be more DRY. Remember that strings can be replaced with Narrative.Text and Narrative.Execute.

Something to also check, are you trying to write these BDD-style of RSpec? I suspect so. If so, think about actually using RSpec on IronRuby! MMmmmmm. That's where I am heading.

I am still using storyq for acceptance tests and find that I don't need much that what is currently available. So, feel free to post examples and we can think about coding solutions.

Cheers todd

Read the full discussion online.

To add a post to this discussion, reply to this email (storyq@discussions.codeplex.com)

To start a new discussion for this project, email storyq@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com