Thomas Sundberg

November 20, 2015

Expected exceptions

Filed under: Java, Programming, TDD — Tags: , , , , — Thomas Sundberg @ 11:27

This post is available at http://www.thinkcode.se/blog/2015/11/20/expected-exceptions

Advertisements

2 Comments »

  1. Hi Thomas!
    There is also a nice little helper library called catch-exception which is here https://github.com/Codearte/catch-exception/tree/2.x
    It allows to check for an exception in a single line,

    verifyException(myList, IndexOutOfBoundsException.class).get(1);

    But then you need an extra library to add.

    Comment by Peter Kofler — November 20, 2015 @ 22:51

    • Hi Peter!

      I don’t see adding a dependency as a bad thing. Not if it allows you to write readable and understandable code.
      I wasn’t aware of the one you mention.

      Thanks!
      Thomas

      Comment by Thomas Sundberg — November 21, 2015 @ 10:16


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: