Hi,
I'm trying out ideas for "Living Documentation", and I was thinking
about creating something like
relishapp.com. (Why? Because I like more
flexibility than what relishapp currently offers).
Since I'm familiar with SpecFlow I naturally thought I'd try to use
that, and SpecFlowLangParser seemed to be a good entry point.
static void Main(string[] args)
{
var parser = new
SpecFlowLangParser(System.Globalization.CultureInfo.CurrentCulture);
string fileName = "SampleFeature.feature";
Feature feature = null;
using(FileStream fileStream = File.OpenRead(fileName))
{
using (var reader = new StreamReader(fileStream))
{
string content = reader.ReadToEnd();
feature = parser.Parse(new StringReader(content),
fileName + ".cs");
}
}
if (feature != null)
{
string text = new SampleTemplate() { Feature =
feature }.TransformText();
using (FileStream writeStream =
File.OpenWrite(fileName + ".html"))
{
using (var streamWriter = new
StreamWriter(writeStream))
{
streamWriter.Write(text);
}
}
}
}
SampleFeature.feature is the standard SpecFlow feature file (the one
about Addition). SampleTemplate is a razor-template that I use to
generate html.
However, I ran into troubles. the call to parser.Parse(...) throws a
SpecFlowParserException with message:
Invalid Gherkin file!
(1,1): Parsing error near 'Feature: Addition'
(2,1): Parsing error near 'In order to avoid silly mistakes'
(3,1): Parsing error near 'As a math idiot'
(4,1): Parsing error near 'I want to be told the sum of two numbers'
(7,1): Parsing error near 'Scenario: Add two numbers'
(8,1): Parsing error near 'Given I have entered 50 into the
calculator'
So obviously my approach was too naive ... could somebody point me in
the right direction? Thanks!
Dirk