Single-Statement Unit Tests

Single-Statement Unit Tests

http://ift.tt/2qX2owO

Many articles and books have already been written about unit testing patterns and anti-patterns. I want to add one more recommendation which, I believe, can help us make our tests, and our production code, more object-oriented. Here it is: a test method must contain nothing but a single assert.

Look at this test method from RandomStreamTest from OpenJDK 8, created by Brian Goetz:

java

via DZone.com Feed https://dzone.com

May 24, 2017 at 07:30PM

Advertisements

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