...

/

A Classic-Style Assertion: assertTrue

A Classic-Style Assertion: assertTrue

This lesson will explain the use and importance of using assertTrue in writing Unit tests.

We'll cover the following...

The most basic Classic-Style Assertion is assertTrue:

org.junit.Assert.assertTrue(someBooleanExpression); 

Since assertions are so pervasive in JUnit tests, most programmers use a static import to reduce the clutter:

import static org.junit.Assert.*; 

An assertTrue ensures that a value is true, otherwise it gives a false. A couple ...