Tip for a forgetful software developer

Lately, when writing JUnit tests I’ve been doing things like:

String result = some.method();
assertTrue("Expected " + expected + " but was " + result, result.equals(expected));

However, a similar result can be achieved with the semantically more accurate

assertEquals(expected, result);

This is even easier to type 🙂

I did know this, honest!

This entry was posted in Software, Work. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

You must be logged in to post a comment.