First time working with MSTest. I’m having trouble googling this because every result is about asserting if a particular type of exception occurred during the test (like you expect a dividebyzeroexception and you’re checking for that) which is not what I’m looking for.
My scenario is simple, my test is calling a service to retrieve data and I simply check that it got back results.
[TestMethod]
public void TestGetData() {
try {
var res = _service.GetData();
Assert.IsTrue(res.Count() > 0);
}
catch (Exception ex) {
//??
}
}
But what if the test fails because the credentials used to call the service’s GetData() method are invalid? or expired/disbaled etc? or any other possible uncaught exception? How do I get access to that underlying exception/stack? The code above will fail the test but the Exception in the catch here is just the stack to the Unit Test class, not the actual stack of what failed in the service. How do I tap into that? It’s not in the InnerException here either. Thanks.