A Beginner’s Guide to Testing Using JUnit

JUnit is a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks.

Introduction

JUnit Basics

Figure 1 — JUnit test runner executes the test class to generate a test report.

Example#1: ArrayListTest

Example#2: LoanTest

Using JUnit from Eclipse

Figure 2— The New Java Project dialog creates a new project.
Figure 3— The New Java Class dialog creates a new Java class.
Figure 4— The Loan class is created.
Figure 5— The New JUnit Test Case dialog box creates a Test class.
Figure 6— The LoanTest class is automatically generated and we modified it.
Figure 7— The test report is displayed after the LoanTest class is executed.

Conclusion

I am a big fan of Real Madric CF and I love computer science!