home recent topics recent posts search faq  

Pretty Objects Visual T# Forum



register | lost password   open id sign in with Twitter
Messages in this topic - RSS

Home » T# Videos » Testing exceptions... the best way!

Videos showing how to use Visual T#
|
10/22/2010 8:13:49 AM

Ludovic Dubois
Ludovic Dubois
Administrator
Posts: 159
What is "the bests way"? (12:36)

  • Simple: one line of code to test that the right exception is thrown:
    assert thrown <exception>; 

  • Complete: test what ever you want on your exception, or any side effects you expect:
    assert thrown <exception> e
    {
      assert e....;
      assert e....;
      ...
    }
     

  • Sure: test that stuff that must not change do not change
    runtest p.Price = -1;
    assert thrown <exception>;
    assert p.Price == 0; // Still the same value

     

  • Right scope: the exception is thrown in the business code, not in the test, even if the same exception is thrown when preparing or verifying the test (before or after runtest statement).

Be sure your business code thrown the right exception at the right time! Cool



Access source code from our svn server at https://www.prettyobjects.com:7567/svn/public/TSharp/Products/?p=17
<em>edited by Ludovic Dubois on 28/10/2010</em>

Attachments:
Business-4.avi
0 permalink
|

Home » T# Videos » Testing exceptions... the best way!





Powered by Jitbit Forum 7.2.14.1 © 2006-2011 Jitbit Software