Aubergine (BDD for .net) v0.05 : text stories/html & custom output/cmdline parser
Again a new release !!
* The stories are now written in text-format; unrecognized beginning of lines are skipped/not processes; example data should begin with/be seperated by "|".
* Commandline parser implemented with help
Edit 3 : v0.06 arrived
C:\Projecten\Be.Corebvba.Aubergine\Be.Corebvba.Aubergine.Examples\Lib>ConsoleRunner.exe /h
Aubergine Console Runner - Core bvba - Tom Janssens 2009
Usage :
ConsoleRunner [wildcard or filename for story file][...] [parameters]
Where parameters can be one of the following :
-html
Output to html unordered lists
-fmthdr,-formatheader XXXX
Header to put before starting the children output; example "<ul>"
-fmt,-formatter XXXX
Named storyformatter; example "<li>{Type} {Description} <a href='#' title='{StatusInfo}'>{StatusText}</a
></li>"
-fmtftr,-formatfooter XXXX
Footer to put after ending the children output; example "</ul>"
-h,-?,-help
Show the syntax of the commandline parameters
An example story :
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 | https://www.google.be/search?q= | BDD .Net | www.corebvba.be |
| bing | https://www.bing.com/search?q= | core bvba tom | www.corebvba.be |
| bing | https://www.bing.com/search?q= | Quantum physics | www.corebvba.be |
| faulty link | https://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
- Scenario Search results for core bvba tom on bing should contain www.corebvba.be OK
- Scenario Search results for Quantum physics on bing 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 https://www.googleaaa OK
- When searching for core bvba tom IMPLEMENTATION ERROR
- Then the result should contain www.corebvba.be NOK
- Story Make sure my website gets enough visibility IMPLEMENTATION ERROR
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...
Edit 2 : Apparently the reference is wrong (rereference Be.corebvba.aubergine.dll under the lib folder)
Enjoy !!