Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The presence of a background causes a crash when integrating test results #238

Closed
smr75 opened this issue Dec 22, 2015 · 8 comments
Closed
Assignees
Labels

Comments

@smr75
Copy link

smr75 commented Dec 22, 2015

I have a Feature file with 3 scenarios and 2 Background steps. The presence of the Background steps causes Pickles.CommandLine to throw a NullReference Exception in the NUnitSingleResults class because the feature.Background.Feature property is not set for Backgrounds. Here is the full stack trace:

ERROR|Runner|Something went wrong during generation: System.NullReferenceException: Object reference not set to an instance of an object.
at PicklesDoc.Pickles.TestFrameworks.NUnitSingleResults.<>c__DisplayClass11_0.b__1(XElement x) in C:\Dev\Code\GitHub\PicklesDoc\pickles\src\Pickles\Pickles\TestFrameworks\NUnitSingleResults.cs:line 101
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source, Func2 predicate)
at PicklesDoc.Pickles.TestFrameworks.NUnitSingleResults.GetScenarioResult(Scenario scenario) in C:\Dev\Code\GitHub\PicklesDoc\pickles\src\Pickles\Pickles\TestFrameworks\NUnitSingleResults.cs:line 63
at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at PicklesDoc.Pickles.TestFrameworks.MultipleTestResults.GetScenarioResult(Scenario scenario) in C:\Dev\Code\GitHub\PicklesDoc\pickles\src\Pickles\Pickles\TestFrameworks\MultipleTestResults.cs:line 99
at PicklesDoc.Pickles.DocumentationBuilders.HTML.HtmlScenarioFormatter.Format(Scenario scenario, Int32 id) in C:\Dev\Code\GitHub\PicklesDoc\pickles\src\Pickles\Pickles\DocumentationBuilders\HTML\HtmlScenarioFormatter.cs:line 65
at PicklesDoc.Pickles.DocumentationBuilders.HTML.HtmlFeatureFormatter.Format(Feature feature) in C:\Dev\Code\GitHub\PicklesDoc\pickles\src\Pickles\Pickles\DocumentationBuilders\HTML\HtmlFeatureFormatter.cs:line 75
at PicklesDoc.Pickles.DocumentationBuilders.HTML.HtmlDocumentFormatter.Format(INode featureNode, GeneralTree1 features, DirectoryInfoBase rootFolder) in C:\Dev\Code\GitHub\PicklesDoc\pickles\src\Pickles\Pickles\DocumentationBuilders\HTML\HtmlDocumentFormatter.cs:line 74 at PicklesDoc.Pickles.DocumentationBuilders.HTML.HtmlDocumentationBuilder.WriteContentNode(GeneralTree1 features, INode node, String htmlFilePath) in C:\Dev\Code\GitHub\PicklesDoc\pickles\src\Pickles\Pickles\DocumentationBuilders\HTML\HtmlDocumentationBuilder.cs:line 104
at NGenerics.Patterns.Visitor.VisitorExtensions.AcceptVisitor[T](IEnumerable1 enumerable, IVisitor1 visitor)
at PicklesDoc.Pickles.Runner.Run(IContainer container) in C:\Dev\Code\GitHub\PicklesDoc\pickles\src\Pickles\Pickles\Runner.cs:line 61

@dirkrombauts
Copy link
Member

Hi,

I'm sorry you ran into troubles. Thank you for taking the time to report this.

Would it be possible for you to attach the feature file and nUnit test results file in question? Thanks!

@dirkrombauts dirkrombauts self-assigned this Dec 22, 2015
@dirkrombauts
Copy link
Member

I'm starting on this now.

@dirkrombauts
Copy link
Member

I am sorry, I am unable to reproduce the issue on my machine. It would really help if you could attach the feature files and the test result file. Thank you.

@smr75
Copy link
Author

smr75 commented Dec 22, 2015

The problem seems to occur with results produced using NUnit console version 2.6.4 (I can't use NUnit v3 as SpecFlow doesn't seem to support it). I've recreated the problem using the simple feature file which I've attached.
[TestResult.txt](https://github.com/picklesdoc/pickles/files/69874/TestResult.txt
TestResult.xml.txt

CustomerOrders.feature.txt

)

The problem seems to be in the following section of code in the Mapper.cs file:

        configurationStore.CreateMap<G.Feature, Feature>()
            .ForMember(t => t.FeatureElements, opt => opt.ResolveUsing(s => s.ScenarioDefinitions))
            .AfterMap(
                (sourceFeature, targetFeature) =>
                    {
                        foreach (var featureElement in targetFeature.FeatureElements.ToArray())
                        {
                            featureElement.Feature = targetFeature;
                        }
                    });

featureElement.Background.Feature property isn't set here which subsequently causes a NullReferenceException in the NUnitSingleResults.cs file, line 101.

@dirkrombauts
Copy link
Member

Thanks for the files, I can reproduce the issue now. And thanks for the analysis too!

@dirkrombauts dirkrombauts changed the title Backgrounds cause NullReference Exception in Pickles.CommandLine The presence of a background causes a crash when integrating test results Dec 23, 2015
@dirkrombauts
Copy link
Member

I released the fix in version 2.0.3

@smr75
Copy link
Author

smr75 commented Dec 23, 2015

Yep, v2.0.3 has fixed the problem. Thanks for the quick turnaround.

@dirkrombauts
Copy link
Member

You're welcome- glad I could help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants