Skip to Content
Effective Unit Testing
book

Effective Unit Testing

by Lasse Koskela
February 2013
Intermediate to advanced content levelIntermediate to advanced
258 pages
7h 26m
English
Manning Publications
Content preview from Effective Unit Testing

4.3. Bitwise assertions

In the beginning of this chapter I described a primitive assertion as one that’s so cryptic because of its low abstraction level that its intent and meaning remain a mystery to the reader. A bitwise assertion is a special case of primitive assertion that I feel warrants special mention because its elements are close to home for so many programmers and far from home for equally many programmers.

Perhaps an example will help concretize this hazard.

4.3.1. Example

Let’s take a look at a concrete example that exhibits this particular smell. Consider the test in this listing.

Listing 4.8. Bitwise assertion, also known as “what did this operator do again?”
public class PlatformTest { @Test public void platformBitLength() { assertTrue(Platform.IS_32_BIT ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Art of Unit Testing, Second Edition

The Art of Unit Testing, Second Edition

Roy Osherove
Testing with JUnit

Testing with JUnit

Leonard Przybylski, Frank Appel

Publisher Resources

ISBN: 9781935182573Publisher SupportOtherPublisher WebsiteErrata PageSupplemental ContentPurchase Link