question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Async with Task<T>

See original GitHub issue

First, 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:closed
  • Created 7 years ago
  • Comments:11

github_iconTop GitHub Comments

2reactions
jayschroedercommented, Jun 23, 2016

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.

0reactions
BrainCrumbzcommented, Jun 24, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found