4.05 out of 5
4.05
127 reviews on Udemy

Learn by Example: JUnit

A comprehensive guide to JUnit with 25 solved examples
Instructor:
Loony Corn
2,894 students enrolled
English [Auto-generated]
Test functionality of Java applications using JUnit
Write test cases using Assertions and Matchers
Create mock objects to test interdependent classes
Run multiple test classes under different conditions

JUnit is one of a family of unit testing frameworks all built with the same philosophy. To abstract the programmer away from the mechanics of running tests. You concentrate on testing the functionality of the application, and the logistics of running, monitoring and displaying results is taken care of by the framework.

In this course, we’ll be writing simple tests using all the different features of JUnit tests. Using 25 solved examples, you’ll get a complete overview of the JUnit framework and all the functionality within.

What’s covered?

1) Assertions : the fundamental component of any Junit test
2) Matchers : Write complicated tests in a very readable way. Implement your own custom matchers
3) Assumptions : Check for preconditions and external dependencies

4) Fixtures : Setup and Cleanup for your tests

5) Runners : Understand what goes on under the hood in JUnit. Use different runners to run multiple test classes with different conditions and parameters
4) Mockito : Understand the concept of mock objects and use the Mockito framework to run tests on interdependent classes.

You, This Course and Us

1
You, This Course and Us

Let's start with an introduction. We'll understand what JUnit can do for us and what's covered in the course. 

Getting Started with JUnit Tests and Assertions

1
Example 1 : The @Test Annotation : Writing a test

Write your very first JUnit test and understand what is happening when a test is run. 

2
Example 2: The Anatomy of a Test Method

What are the different things you need to do in a test? Every test is made up of 3 basic steps - understand this to test any class. 

3
Example 3: Assertions

The Assert class provides many methods to check different conditions against different types of objects. 

Granular Checks with Matchers

1
Example 4: assertThat and Matchers

Make complex checks more readable with the help of matchers. 

2
Example 5: Types of Matchers

Understand the different methods available in the Matchers class

3
Example 6: Using Matchers for Debugging

Error messages for Matchers are very verbose and help with debugging! 

4
Example 7: Implementing a Custom Matcher

Implement a custom matcher, when you have a special requirement not already handled! 

Assumptions

1
Example 8: Checking Preconditions with Assumptions

Use Assumptions to check that preconditions and external dependencies are set up correctly.

Fixtures

1
Example 9: Using Fixtures for Setup and Cleanup

Fixtures are used for setup and cleanup. Ex: Setting up common objects, starting and closing server/database/file connections. 

Working with Different TestRunners

1
Example 10: The @RunWith Annotation

JUnit allows you to specify different Test Runners, each with different ways to control how your tests are run

2
Example 11: Aggregating tests in a Suite

Run multiple tests at at time.

3
Example 12: Parameterized Tests

Run tests with different values for certain parameters.

4
Example 13: Running Subsets of Tests
5
Example 14: Theories

Run tests with different sets of assumptions.

Controlling Test Behavior with Rules

1
Example 15: External Resource Rules
2
Example 16: The Temporary Folder Rule
3
Example 17: Error Collector Rule
4
Example 18: Verifier Rule
5
Example 19: Test Watcher Rule
6
Example 20: TestName Rule
7
Example 21: ExpectedException Rule
8
Example 22: Timeout Rule
9
Example 23: Class Rule

Mockito : The Mock Object Framework

1
Example 24: Creating Mock Objects and Verifying Interactions
2
Example 25: Stubbing Objects for Expected Results
You can view and review the lecture materials indefinitely, like an on-demand channel.
Definitely! If you have an internet connection, courses on Udemy are available on any device at any time. If you don't have an internet connection, some instructors also let their students download course lectures. That's up to the instructor though, so make sure you get on their good side!
4.1
4.1 out of 5
127 Ratings

Detailed Rating

Stars 5
52
Stars 4
44
Stars 3
23
Stars 2
6
Stars 1
2
72ae6dcaafb7ec45655c9b3b0ae05c9c
30-Day Money-Back Guarantee

Includes

3 hours on-demand video
Full lifetime access
Access on mobile and TV
Certificate of Completion