Closed lkaczanowski closed 5 years ago
TickSpec has two implementations of execution:
.NET Core implementation doesn't support second type of implementation as we haven't find a way to tell in generated IL how it maps to a feature file. So, when you use today NUnit fixture it will typically use second implementation for .NET framework tests and first implementation for .NET Core tests.
I was focusing on step methods only when I was implementing functional injection. The reason that registration within BeforeScenario works in "simple execution" case is a luck, the implementation reuses invoke method between step methods and events (like BeforeScenario).
It makes sense to improve the implementation to support functional injection for events in IL generation case (ScenarioGen.fs). Note that I am not sure that "simple execution" handles requesting something from DI container within events - we may want to implement that, too. Let me know if you want to work on that, I can help.
Workaround for you can be to use "simple execution" implementation - e.g. by using .NET standard version of TickSpec or by modifying FeatureFixture.cs in your project so that it uses the ScenarioRun type of the execution.
Thank You for the quick answer. I will use workaround for now but I can help fixing this issue as well. I can start working on it next week though.
I'm working on .NET Framework test project with TickSpec and NUnit. When using BeforeScenario attribute with functional injection coding style I am getting System.InvalidProgramException.
Steps to reproduce on TickSpec solution:
open NUnit.Framework open Retail open TickSpec
let [] BeforeScenario () =
{ Count = -1 }
let []
a customer buys a black jumper
() = ()let []
I have (.*) black jumpers left in stock
(n:int) (stockItem:StockItem) ={ stockItem with Count = n }
let []
he returns the jumper for a refund
(stockItem:StockItem) ={ stockItem with Count = stockItem.Count + 1 }
let []
I should have (.*) black jumpers in stock
(n:int) (stockItem:StockItem) =let passed = (stockItem.Count = n) Assert.True(passed)
[0-1001]NUnit.TickSpec+FeatureFixture.Scenario 1: Refunded items should be returned to stock
System.InvalidProgramException : Common Language Runtime detected an invalid program. at Scenario 1: Refunded items should be returned to stock.Run() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at NUnit.TickSpec.FeatureFixture.Bdd(Scenario scenario) in C:\sources\TickSpec\Examples\ByFeature\FunctionalInjection\NunitWiring.fs:line 21