Async with Task<T>
See original GitHub issueFirst, still learning the TDD / BDD mindset and I’m really liking NSpec, thanks for your time and effort.
The documentation isn’t real clear as to how the runner handles hooks marked with Async (beforeAsync, actAsync, …). Does the runner wait for task completion so that “it” specs properly (ex: “beforeAsync” makes sure its operation is complete so “it” specs can evaluate results)?
I’m using Task<T>
but it causes a runtime error (below). From the error message it appears the issue is the runner can only handle Task (not the generic version)?
Exception executing context: nspec. Verify list. given 1 valid switch
System.Reflection.TargetInvocationException: Exception has been thrown by the ta
rget of an invocation. ---> System.MissingMethodException: Method not found: 'Vo
id NSpec.nspec.set_beforeAsync(System.Func`1<System.Threading.Tasks.Task>)'.
Jay
Issue Analytics
- State:
- Created 7 years ago
- Comments:11
Top Results From Across the Web
Asynchronous programming - C# | Microsoft Learn
The core of async programming is the Task and Task<T> objects, which model asynchronous operations. They are supported by the async and await...
Read more >Asynchronous programming with async, await, Task in C#
The await keyword waits for the async method until it returns a value. So the main application thread stops there until it receives...
Read more >Async and Await in C#
The "async" keyword marks a method asynchronous, meaning it can be run in the background while another code executes. When you mark a...
Read more >Async and Await in C# - GeeksforGeeks
Async and Await are the two keywords that help us to program asynchronously. An async keyword is a method that performs asynchronous tasks...
Read more >C# async await explained (2023)
The await keyword is followed by a Task or Task<TResult> object. It suspends the current thread execution until the task is completed. The...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok, I finally got to the bottom of my problem (and I’m embarrassed). I now recall when I first looked at NSpec I did not understanding nuget, so I did what was familiar - download the zip, extract to a directory and I also added an External Tool menu item to VS to call the runner. I read up on nuget and tried it on my home computer until I felt comfortable to do the same on my work computer. Unfortunately, my project was compiling against the latest version dll but I forgot to change the External tool menu so it was calling an earlier version of the runner. What’s interesting is that I didn’t see any problems until I introduced async code. All is well now, works great any my test code is far more understandable. Thanks again for your time.
Not sure you’re bound to some dev environment constraint, but maybe you can give a go to VS Community Edition (2013 or 2015), as those are more powerful than Express editions.