Bikeshed: Where Does the Expected Value Go?

| Comments

Does the expected value of a unit test assertion go on the right or the left side?

Option 1: Expected Value on Left

    assert "Aaron Oliver" == user.fullname()

Option 2: Expected Value on Right

    assert user.fullname() == "Aaron Oliver"

Yes, it’s a bikeshed issue, but I think it’s worth discussing. Mixing conventions is confusing.

I think option 2 is closer to how we speak and think about test assertions:

Verify the result is what was expected

However, I’ve been doing option 1 since my Java days, I think because that’s how JUnit wants it.

What’s the best way?

blog comments powered by Disqus

About this Entry

This page contains a single entry by Aaron Oliver published on July 14, 2009 9:08 PM.

Vimspiration was the previous entry in this blog.

Commit EVERYTHING is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Categories

Creative Commons License
This blog is licensed under a Creative Commons License.