我想使用storyQ将此单元测试转换为BDD 工作单元测试
I want to convert this unit test into BDD using storyQ working unit test
[Test] public async void CreateNewProjectAndDatabase() { StartParametersAndAteEngineDlls(); await TheNewDatabaseAndProjectIsCreated(); TheDataBaseViewModelIsCreated(); TheMainViewModelIsCreated(); } private async Task TheNewDatabaseAndProjectIsCreated() { .... }转换为BDD
[Test] public async Task CreateNewProjectAndDatabase() { _story.WithScenario("Create a new bla bla") .Given(StartParametersAndAteEngineDlls) .When(async ()=> await TheNewDatabaseAndProjectIsCreated()) .Then(TheDataBaseViewModelIsCreated) .And(TheMainViewModelIsCreated) .Execute(); }代码正在编译,但是我得到了ArgumentException 如果您在方法名称中使用2个下划线,请确保有2个参数(找到0)
the code is code is compiling however I get an ArgumentException If you use 2 underscores in your method name, make sure there's 2 arguments (found 0)
推荐答案我知道我来晚了.我遇到了同样的问题,我修改了它的执行方式,更改了When方法的执行方式.我没有使用await和执行任务,而是在While方法中使用了oldSchool函数"Wait".这样,我们可以拥有StoryQ可以理解的私有void函数.
I know I'm a bit late. I had the same problem I fixed it changing the way I execute the When method. Instead of using await and having a Task I used the oldSchool function "Wait" inside the When method. In that way we can have a private void function that StoryQ understand.
类似这样的东西.
private void MyWhenMethod() { _sut.AsyncMethodRun().Wait() }更多推荐
StoryQ When()调用任务C#
发布评论