unit tests and exception

2012-03-21 Thread Stephen Price
Cross posting this, I'm on too many lists. Hope that doesn't offend... I've got a unit test that is throwing an exception. (Finally got it hitting my catch block) Its a smoke test so has a loop in it for every view. I want it to NOT fail the test if an exception is hit. I want it to output to debu

Re: unit tests and exception

2012-03-21 Thread Wallace Turner
[TestMethod] [ExpectedException(typeof(InvalidOperationException))] public void Foor() { On 22/03/2012 10:35 AM, Stephen Price wrote: Cross posting this, I'm on too many lists. Hope that doesn't offend... I've got a unit test that is throwing an exception. (Finally got i

Re: unit tests and exception

2012-03-21 Thread Stephen Price
Tried that. It then passes the test as soon as the exception is hit. not what I want, I just want it to handle the exception. Interestingly, its saying theres a null exception unhandled despite me having a catch. How do you handle nested exceptions? Nested try catch's? I'm grasping at straws here.

Re: unit tests and exception

2012-03-21 Thread Wallace Turner
what unit test runner are you using ? On 22/03/2012 10:59 AM, Stephen Price wrote: Tried that. It then passes the test as soon as the exception is hit. not what I want, I just want it to handle the exception. Interestingly, its saying theres a null exception unhandled despite me having a catc

Re: unit tests and exception

2012-03-21 Thread Wallace Turner
this passes for me. [TestMethod] public void Test1() { try { throw new Exception("foo"); } catch (Exception e) { } } On 22/03/2012 10:59 AM, Stephen Price wrote: Tried that. It the

Re: unit tests and exception

2012-03-21 Thread Stephen Price
Ok, I must have an unhandled exception getting through still. What happens if more than one exception is thrown? Maybe its related to the unit test running asyncronously? I'm thinking its going to be more work but might be better to have a single unit test per view. On Thu, Mar 22, 2012 at 11:07

RE: unit tests and exception

2012-03-21 Thread David Kean
bject: Re: unit tests and exception Ok, I must have an unhandled exception getting through still. What happens if more than one exception is thrown? Maybe its related to the unit test running asyncronously? I'm thinking its going to be more work but might be better to have a single unit tes

Re: unit tests and exception

2012-03-21 Thread Wallace Turner
Run the unit test debugging and ensure you have break on exceptions ticked: On 22/03/2012 11:10 AM, Stephen Price wrote: Ok, I must have an unhandled exception getting through still. What happens if more than one exception is thrown? Maybe its related to

RE: unit tests and exception

2012-03-21 Thread David Kean
If you have Just My Code turned on, then you shouldn't need to do this. It will break earlier. From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Wallace Turner Sent: Wednesday, March 21, 2012 8:13 PM To: ozDotNet Subject: Re: unit tests and exception

RE: unit tests and exception

2012-03-21 Thread David Kean
I mean, it will/it should break in the last user code. From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of David Kean Sent: Wednesday, March 21, 2012 8:23 PM To: ozDotNet Subject: RE: unit tests and exception If you have Just My Code turned on, then you

Re: unit tests and exception

2012-03-21 Thread Stephen Price
et.com] *On Behalf Of *David Kean > *Sent:* Wednesday, March 21, 2012 8:23 PM > *To:* ozDotNet > *Subject:* RE: unit tests and exception > > ** ** > > If you have Just My Code turned on, then you shouldn’t need to do this. It > will break earlier. > > ** ** >

Re: unit tests and exception

2012-03-21 Thread DotNet Dude
On Thu, Mar 22, 2012 at 1:35 PM, Stephen Price wrote: > Cross posting this, I'm on too many lists. Hope that doesn't offend... > > I've got a unit test that is throwing an exception. (Finally got it hitting > my catch block) Its a smoke test so has a loop in it for every view. I want > it to NOT f

Re: unit tests and exception

2012-03-21 Thread Stephen Price
Debug.WriteLine("Error {0} while loading {1}", e.Message, uri); uri being the string uri of the view in question... On Thu, Mar 22, 2012 at 1:24 PM, DotNet Dude wrote: > On Thu, Mar 22, 2012 at 1:35 PM, Stephen Price > wrote: > > Cross posting this, I'm on too many lists. Hope that doesn't o