jUnit Quickstart
jUnit is a framework for writing and running test cases—http://junit.org/. A test is a Java class containing jUnit annotations to set up the test and identify test methods. Basically, you annotate test methods with the @Test annotation and verify results using assertion. When you want to check a value dependent on the nature of the check and the type of the value, you call the appropriate assertion.
For example, if you want to check that the value of a Boolean variable is true, you would write: assertTrue(var). There are many different assertions located in package import org.junit.Assert.*. Notice that you have to import this package statically to each test class. Methods containing test code are annotated with @org.junit.Test ...
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.
Read now
Unlock full access