Exercises in Unit Testing for Java Developers

How to write test code in a straightforward way.

This course points out the importance of unit testing, from a preventive point of view, since  it is a task that represents the intersection between software development and software testing, corroborated by a workshop with a couple of exercises using Eclipse IDE and JUnit.

What you’ll learn

  • Understanding the importance of testing activity from developers point of view.
  • The advantages of unit testing.
  • How to write test code from main code..
  • How to anticipate pessmistic scenarios before writing main code..

Course Content

  • Introduction –> 1 lecture • 1min.
  • Why test code –> 2 lectures • 3min.
  • Workshop Configuration and Preparation –> 2 lectures • 2min.
  • JUnit Worshop –> 2 lectures • 28min.
  • Conclusion –> 1 lecture • 1min.

Exercises in Unit Testing for Java Developers

Requirements

This course points out the importance of unit testing, from a preventive point of view, since  it is a task that represents the intersection between software development and software testing, corroborated by a workshop with a couple of exercises using Eclipse IDE and JUnit.

Indeed, JUnit allows the execution of test cases independently, using specific annotations.

Eclipse IDE provides a useful plugin called JUnit-Tools that generates test classes in a easy and fast manner.

Assertions (provided by JUnit) are essential when it comes to verifying results produced by tested methods. However, sometimes, test cases’ expected result is an Exception. JUnit, provides the necessary semantic to address this situation. It is important to note that expected and actual are two important keywords to use for variables when working with assertions.

This course is outlined as the following:

  • Introduction​
  • Software Testing​
    • Unit Testing​
    • Integration Testing​
  • Why Test code ?​
  • Best approach for developers ?​
  • JUnit Workshop​
  • Conclusion​

Resources:

  • “Clean Code: A Handbook of Agile Software Craftsmanship” by Robert C. Martin (Fifteenth printing, September 2015);
  • “Head First Java, Second Edition” by Kathy Sierra & Bert Bates;
  • “Software Engineering, Ninth Edition” by Ian Sommerville.

Workshops prerequisites:

  • Java 8+
  • Eclipse IDE (or any IDE of your choice)
  • JUnit 5
  • Maven
Get Tutorial