I have some tests that run through the workflow of my WPF program. I do the normal MVVM approach which is binding buttons on the view to commands on the view model, which then handles the event. The way my tests test my workflow is then by directly executing the commands on the view model. This roughly translates to look something like:
[Test]
public void Test()
{
var vm = new ViewModel();
vm.AcceptCommand.Execute();
Assert.IsTrue(stuff);
}
All of this works well, except for the fact that the code in the viewmodel that handles the command ends up being an async void method since this just becomes an event handler. If an exception gets thrown here, nunit does not show a failing test because it doesn't "see" this exception in the background thread.
My question is: is there a way to get NUnit to handle these background exceptions?