JUnit is the most popular and widely used Java unit testing framework.
This hands-on course, delivered using JUnit v5, comprises sessions dealing with unit testing, setup, annotations, assertions and assumptions, conditional tests, parameterised tests, stubbing and mocking, Mockito, DAO and Servlet testing, testing multi-threaded code, and TDD.
Exercises and examples are used throughout the course to give practical hands-on experience with the techniques covered.Who will the Course Benefit?
This Unit Testing with JUnit course will benefit Java developers and testers who are new to JUnit and/or unit testing more generally.Course Objectives
This course aims to provide the delegate with the knowledge to be able to design and code good quality, isolated unit tests with JUnit that exploit all the features of the JUnit framework.
Upcoming start dates
In-House training available upon request
- In Company
- United Kingdom
Virtual and Hybrid options are available upon request
- Virtual Classroom
Suitability - Who should attend?
Delegates attending this course should be familiar with basic programming concepts and have some experience coding with Java at least. Ideally delegates will be competent Java developers who have a good understanding of OO principles and are able to build simple applications that exploit APIs including Collections, IO, and JDBC. This knowledge can be obtained by attendance on the pre-requisite Java Programming 1 / Java Developer course.
JUnit 5 exploits modern Java features including lambda expressions. Some experience or familiarity with such features, therefore, is desirable. These skills can be obtained by attendance on the Java Programming 2 / Java Advanced Developer course.
Experience to the level as demonstrated in this course is recommended:
- Java Programming 1 / Java Developer
Training Course Content
Unit Testing with JUnit Training Course
Course Contents - DAY 1Course Introduction
- Administration and Course Materials
- Course Structure and Agenda
- Delegate and Trainer Introductions
- What is unit testing
- The purpose of unit testing
- The structure of a test
- Code coverage
- Guidelines for writing good unit tests
- Other types of testing
- What is JUnit
- The main features of JUnit
- JUnit in IntelliJ
- JUnit with Maven/Gradle
- A simple unit test
- Alternatives to JUnit
Course Contents - DAY 2Session 5: CONDITIONAL TESTS
- OS conditions
- CRE conditions
- System property conditions
- Environment variable conditions
- Custom conditions
- What is a parameterised test
- The junit-jupiter-params artefact
- Consuming arguments
- Argument sources
- Argument conversion
- Argument aggregation
- Customising display names
- Test doubles/fake objects
- What is Mockito
- The mockito-core and mockito-junit-jupiter artefacts
- The Mockito JUnit extension
- Creating a mock/spy
- Setting expectations (when, then)
- Argument matchers
- Verifying behaviour
- Mocking static methods
Course Contents - DAY 3Session 9: IO, DAO, & SERVLET TESTING
- Testing methods that use IO streams
- Testing DAOs by rolling back transactions
- Moving business logic out of the Servlet to simplify testing
- Sharing data among threads (a review)
- The difficulty in testing concurrent applications
- Testing the code with one thread
- Testing the code with many threads
- The problem with non-deterministic tests
- 3rd-party libraries
- Best practices
- What is TDD
- The pros and cons of TDD
- The three rules
- The red green refactor lifecycle
Customer Outreach Award
We believe that it should be easy for you to find and compare training courses.
Our Customer Outreach Award is presented to trusted providers who are excellent at responding to enquiries, making your search quicker, more efficient and easier, too.
Why StayAhead. From a single person on a scheduled course to large scale training projects StayAhead Training have the expertise and experience to help. Established since 1992, StayAhead Training is recognised as one of the leading independent IT Training specialists...