Click here to Skip to main content
Click here to Skip to main content

Aubergine (BDD for .net) v0.05 : text stories/html & custom output/cmdline parser

By , 12 Nov 2009
Rate this:
Please Sign up or sign in to vote.
Context    Be.Corebvba.Aubergine.Examples.Website.Contexts.BrowserContext
ContextDLL Be.Corebvba.Aubergine.Examples.DLL

Story Make sure my website gets enough visibility. As a website owner I want to make sure that I get enough visibility So that I can get enough traffic.

Scenario Search results for keywords on searchengine should contain my URL.

  • Given the current URL is search URL
  • When searching for keywords
  • Then the result should contain my URL
        +--------------+--------------------------------+------------------+-----------------+
        | searchengine | search url                     | keywords         | my url          |
        +--------------+--------------------------------+------------------+-----------------+
        | google       | http://www.google.be/search?q= | BDD .Net         | www.corebvba.be |
        | bing         | http://www.bing.com/search?q=  | core bvba tom    | www.corebvba.be |
        | bing         | http://www.bing.com/search?q=  | Quantum physics  | www.corebvba.be |
        | faulty link  | http://www.googleaaa           | core bvba tom    | www.corebvba.be |
        +--------------+--------------------------------+------------------+-----------------+

The code is still the same :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Web;
using Be.Corebvba.Aubergine.Model;

namespace Be.Corebvba.Aubergine.Examples.Website.Contexts
{
    public class BrowserContext
    {
        public string Url { get; set; }
        public string Result { get; set; }

        private WebClient wc = new WebClient();
            
        [DSL("the current url is (?<url>.*)")]
        void SetUrl(string url)
        {
            Url = url;
        }

        [DSL("searching for (?<keywords>.*)")]
        void SearchForKeyWords(string keywords)
        {
            Result = wc.DownloadString(Url + HttpUtility.UrlEncode(keywords));
        }

        [DSL("the result should contain (?<myurl>.*)")]
        bool ResultShouldContain(string myurl)
        {
            return (Result??"").Contains(myurl);
        }
    }
}

And this is the resulting output (please try to hover over the implementation error of the "When" step with your mouse !!

Edit : apparently my blog engine team messes up the list layout !!! It are nested list items (although you can not see it here).

Processing file(s) : Website\Stories\*.txt

  • Story Make sure my website gets enough visibility IMPLEMENTATION ERROR
    • Scenario Search results for BDD .Net on google should contain www.corebvba.be OK
      • Given the current url is http://www.google.be/search?q= OK
      • When searching for BDD .Net OK
      • Then the result should contain www.corebvba.be OK
    • Scenario Search results for core bvba tom on bing should contain www.corebvba.be OK
      • Given the current url is http://www.bing.com/search?q= OK
      • When searching for core bvba tom OK
      • Then the result should contain www.corebvba.be OK
    • Scenario Search results for Quantum physics on bing should contain www.corebvba.be NOK
      • Given the current url is http://www.bing.com/search?q= OK
      • When searching for Quantum physics OK
      • Then the result should contain www.corebvba.be NOK
    • Scenario Search results for core bvba tom on faulty link should contain www.corebvba.be IMPLEMENTATION ERROR
      • Given the current url is http://www.googleaaa OK
      • When searching for core bvba tom IMPLEMENTATION ERROR
      • Then the result should contain www.corebvba.be NOK

Processing file:

C:\Projecten\Be.Corebvba.Aubergine\Be.Corebvba.Aubergine.Examples\bin\Release\
    Website\Stories\Make_sure_my_Website_gets_enough_traffic.txt 

This is the postbuildstep now :

"$(ProjectDir)\lib\ConsoleRunner.exe" Accounts\Stories\*.txt Website\Stories\*.txt -html > "$(TargetDir)output.html"
"$(TargetDir)output.html"
exit 0

Include all the stories/txt-file in your project with the option of "copy to output directory" = "always" on each file...

More details/a codeproject article update will follow later...

Enjoy !!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Tom Janssens
Founder Core bvba
Belgium Belgium
Tom Janssens, owner of Core, a software and consultancy company.
Father of two sons named Quinten & Matisse, and married to a beautiful woman named Liesbeth.
 
Blog: http://tojans.me
Github: http://github.com/ToJans
Twitter: http://twitter.com/ToJans
LinkedIn: http://www.linkedin.com/in/tomjanssens

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 12 Nov 2009
Article Copyright 2009 by Tom Janssens
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid