Video description
JUnit is a unit testing framework for the Java programming language.
JUnit has been important in the development of test-driven development and is one of a family of unit testing frameworks which is collectively known as xUnit frameworks.
In this beginners tutorial on JUnit, you will learn how to
- Create a new project for JUnit tests
- Create, run and debug JUnit tests
- Write good unit tests
- Use assert methods
- Use basic JUnit annotations - @Test, @Before, @After, @AfterClass, @BeforeClass, @Suite
- Test performance and exceptions in unit tests
- Write parameterized tests
- Adhere to JUnit best practices
- Use Eclipse to write and run JUnit tests
What You Will Learn
- Write clean unit tests with the JUnit framework
- Use JUnit annotations @Test, @Before, @After, @AfterClass, @BeforeClass, @Suite
- Use JUnit assert methods
- Write unit tests for exceptions and performance
Audience
Students new to unit testing and who want to understand unit testing. Students who want to understand the JUnit framework. Students with basic Java knowledge.
About The Author
In28Minutes Official: Ranga Karanam is a seasoned technologist and architect with over two decades of expertise in programming, design, and architecture. He founded in28Minutes with the goal of helping students master cutting-edge cloud-native technologies such as AWS, Azure, Google Cloud, Docker, and Kubernetes. With 15 years of experience in Java programming and design, Ranga has collaborated with top banking clients worldwide.
His passion for creating hands-on courses with real-world projects motivated him to develop the Step-By-Step series of courses that follow a problem-solution-based approach, with practical and real-world application examples.
Ranga and his team at in28Minutes specialize in Java and related frameworks such as Spring, Spring Boot, Spring MVC, Struts, and Hibernate. They are committed to equipping learners with the skills and knowledge necessary to succeed in today’s rapidly evolving technology landscape.
Table of contents
-
Chapter 1 : JUnit 5
- Introduction
- Course Overview
- Step 01 - Introduction to Unit Testing - Test Pyramid
- Step 02 - First Junit Test - Red bar
- Step 03 - Absence of failure is success
- Step 04 - First Unit Test with JUnit - String length() method
- Step 05 - Writing JUnit Assertions - assertNull and assertTrue
- Step 06 - Writing Assertions for Arrays - assertArrayEquals
- Step 07 - Setting up data for every test - @BeforeEach, @AfterEach
- Step 08 - Setting up database connections - @BeforeAll, @AfterAll
- Step 09 - Tip - Testing Exceptions with Junit
- Step 10 - Tip - @DisplayName and test methods need not be public
- Step 11 - Basics of Parameterized tests
- Step 12 - Advanced Paramaterized Tests with Csv Source
- Step 13 - Tip - Giving a name to a Parameterized Test
- Step 14 - Tip - Repeat same test multiple times
- Step 15 - Tip - Unit Testing for Performance
- Step 16 - Tip - Disable Unit Tests
- Step 17 - Tip - Grouping Tests with @Nested
- Step 18 - Tip - JUnit 5 = Platform + Jupiter + Vintage
- Step 19 - Tip - JUnit 4 vs JUnit 5
- Step 20 - Tip - JUnit Best Practices
- Step 21 - Tip - JUnit Patterns - xunitpatterns
-
Chapter 2 : JUnit 4
- Step 99 - JUnit 4 Section - First Version of the course
- Getting Ready for Hello World
- Your First JUnit Success - Green Bar
- Refactoring: Improving the Junit
- assertTrue and assertFalse
- @Before and @After
- @BeforeClass and @AfterClass
- Comparing Arrays - assertArrayEquals
- Unit Testing Exceptions
- Unit Testing for Performance
- Parameterized JUnit Tests
- Organizing Unit Tests into Suites
- How do you write good Unit Tests?
- Conclusion
Product information
- Title: Learn Java Unit Testing with JUnit 5 in 20 Steps
- Author(s):
- Release date: May 2018
- Publisher(s): Packt Publishing
- ISBN: 9781789340648
You might also like
video
JUnit and Mockito Unit Testing for Java Developers
Are you looking for a simple, no-nonsense guide to learning how unit testing works? This video …
book
Java Unit Testing with JUnit 5: Test Driven Development with JUnit 5
Explore the new way of building and maintaining test cases with Java test driven development (TDD) …
book
JUnit in Action, Third Edition
JUnit is the gold standard for unit testing Java applications. Filled with powerful new features designed …
book
Mastering Software Testing with JUnit 5
A comprehensive, hands-on guide on unit testing framework for Java programming language About This Book In-depth …