I use the specflow nunitexecutionreport
command to produce html reports of my tests and I copy it to a folder where i have the timestamp of the, the report, the generated html and the screenshots taken upon success or failure(all done programatically). But the folder's html report does not have the feature file text of that time. I want to know how, for each test i can get the feature file text at runtime so i can copy it to that folder.
-
@AlSki I don't want to present all my feature files. I want to have in my result.html witch i am building by hand in c#, the original feature text – Luís Marinho Dinis Ferreira Dec 10 '12 at 11:25
-
1Okay, Can you explain what you are trying to do? Not the technical issue, but what are you trying to acheive? – AlSki Dec 10 '12 at 14:09
-
Also, there could be disconnect between what was recorded at the time of generating the html and the *current* version of the linked file. By embedding the content you avoid that disconnect. – AlSki Dec 10 '12 at 14:11
-
@AlSki i've re-written the question – Luís Marinho Dinis Ferreira Dec 10 '12 at 14:55
2 Answers
This isn't really an answer but I need to give a formatted response so this will need editing later
Do you really need to this by rewriting the wheel, or at least do you really need to rewrite the test runner process?
For example the following output comes from TeamCity running NUnit over a specflow generated tests.
[20:29:38][MyCode.Tests.dll] MyCode.Tests.MyFeature.Reload
[20:29:38][MyCode.Tests.MyFeature.Reload] Given I have a config reloader
[20:29:38][MyCode.Tests.MyFeature.Reload] -> done: ConfigReloadTests.GivenIHaveAConfigReloader() (0.1s)
[20:29:38][MyCode.Tests.MyFeature.Reload] And a config A that will unload
[20:29:38][MyCode.Tests.MyFeature.Reload] -> done: ConfigReloadTests.GivenAConfig("A") (0.0s)
[20:29:38][MyCode.Tests.MyFeature.Reload] And a config B that wont unload
[20:29:38][MyCode.Tests.MyFeature.Reload] -> done: ConfigReloadTests.GivenAConfigThatWontUnload("B") (0.0s)
[20:29:38][MyCode.Tests.MyFeature.Reload] When I reload my configs
[20:29:38][MyCode.Tests.MyFeature.Reload] -> done: ConfigReloadTests.WhenIReloadMyConfigs() (0.3s)
[20:29:38][MyCode.Tests.MyFeature.Reload] Then I should have 2 instances
[20:29:38][MyCode.Tests.MyFeature.Reload] -> done: ConfigReloadTests.ThenIShouldHaveInstances(2) (0.1s)
Now this is a standard out of the box result, it would take maybe fifteen minutes to set up. Its fully supported, and its available free. Or do you need something custom that I'm missing from your question?

- 6,868
- 1
- 26
- 39
-
The project that i'm working on requires all to be custom made – Luís Marinho Dinis Ferreira Dec 10 '12 at 14:54
-
IF you can guarantee you are using NUnit to run the Specflow tests then you can write an NUnitAddin which can pick up the Specflow output as it runs. I've previously done this for a personal project.
You register with one class
[NUnitAddin(
Name = "RedGreenRefactor.DatCapture.NUnitAddIn",
Description = "Captures both test data and test output so that SpecFlow steps can be correctly consolidated by RedGreenRefactor",
Type=ExtensionType.Core)]
public class Addin : IAddin
{
public bool Install(IExtensionHost host)
{
IExtensionPoint listeners = host.GetExtensionPoint("EventListeners");
if ( listeners == null )
return false;
listeners.Install( new NUnitCapture() );
return true;
}
}
And the core of your addin looks like this
public class NUnitCapture : NUnit.Core.EventListener
{
...
public void TestOutput(NUnit.Core.TestOutput testOutput)
{
var text = testOutput.Text.Trim();
Debug.WriteLine(String.Format("[{0}]", text));
if (text.StartsWith("Given")
|| text.StartsWith("When")
|| text.StartsWith("Then")
|| text.StartsWith("And"))
{
CreateStep(testOutput);
return;
}
if (text.StartsWith("-> done"))
{
SetStepToSuccess();
return;
}
if (text.StartsWith("-> error"))
{
SetStepToFail();
return;
}
if (text.StartsWith("-> No matching step definition found for the step."))
{
SetStepToPending();
return;
}
}

- 6,868
- 1
- 26
- 39
-
I am using nunit and i will try that. Thanks.I'll let you know. – Luís Marinho Dinis Ferreira Dec 10 '12 at 16:07