Unit Testing with JUnit 5 & Mocking (with Best Practices)(TT3526)
Code:
TT3526
Duration:
3 Day
|
$2195
USD
|
JUnit 5 and EasyMock make it possible to write higher-quality Java code. These powerful tools are designed to support robust, predictable and automated testing development in the Java enterprise application arena.
Unit Testing Essentials using JUnit 5 and Mockito is a three-day, hands-on unit testing course geared for experienced developers who need to get up and running with essential unit testing skills using JUnit, Mockito, and other tools. Students will leave the course armed with the skills required to leverage solid unit testing practices using the latest industry techniques and best practices. This course quickly introduces developers to the features of JUnit and educates them regarding JUnits strengths and weaknesses.
This course is available in the following formats:
Duration: 3 Day
Duration: 3 Day
Call 800-798-3901 to enroll in this class! |
This skills-centric course is about 50% hands-on lab and 50% lecture, designed to train attendees in core unit testing skills, coupling the most current, effective techniques with the soundest industry practices. Working in a hands-on learning environment, guided by our expert team, attendees will learn to:
- Understand what unit testing is and what it is not intended to cover
- Understand JUnit 5.
- Understand and use the JUnit Test Runner interface.
- Use JUnit to drive the implementation of Java code.
- Test applications using native IDE support.
- Best practices and patterns for unit testing.
- Understand JUnits strengths and weaknesses
- Understand the role of debugging when done in conjunction with tests.
- Understand not only the fundamentals of the TDD using Java, but also its importance, uses, strengths and weaknesses.
- Understand how JUnit affects your perspective on development and increases your focus on a task.
- Learn good JUnit coding style.
- Create well-structured JUnit programs.
- Understand how JUnit testing can be used for either state-based or interaction-based testing.
- How to extend testing with mock objects using Mockito.
- Look at refactoring techniques available to make code as reusable/robust as possible.
- Discuss various testing techniques.
The following JUnit-based testing frameworks are examined:
- JUnit 5, Mockito, PowerMock
Session: Unit Testing using Junit
Lesson: Unit Testing Fundamentals
- Purpose of Unit Testing
- Good Unit Tests
- Test Stages
- Unit Testing Vs Integration Testing
- Understanding Unit Testing Frameworks
Lesson: Jumpstart: JUnit 5.x
- Understand and work with the features of JUnit
- Write unit tests using @Test annotation
- Use @DisplayName to specify a custom name for the test
- Manage fixtures using @BeforeEach, @AfterEach, @BeforeAll and @AfterAll annotations
- Launch tests using @ExtendWith (@RunWith JUnit 4+) annotation
- Build test suites using @SelectPackages or @SelectClasses
- Use @Disabled to prevent a test class or method from running
Lesson: Annotations
- Describe the test execution cycle
- Check for exceptions thrown by test
- Use timeouts to fail test that take longer than required
Lesson: Hamcrest
- Learn the notation of assertThat
- Know the objective of Hamcrest library
- Use Hamcrest's logical and object matchers
- Use Hamcrest's number and collection matchers
Lesson: Parameterized Tests
- The @ParameterizedTest annotation
- A parameterized test to test code under several conditions
- Generic tests to support parameterized testing
Lesson: Advanced Features
- Nested Unit Tests
- Repeated Tests
- JUnit Extensions
- Conditions
- Lambda Support
- Grouped Assertions
Lesson: JUnit Best Practices
- "Good" Tests
- Bad Smell
- White-Box Unit Testing
- Black-Box Unit Testing
- Automation and Coverage
Session: Advanced Topics
Lesson: Mocking of Components
- Why We use Test Dummies
- Mock Objects
- Working with Mock Objects
- Using Mocks with the User Interface
- Mock Object Strategies
Lesson: Mock Objects and Mockito
- Mockito Description and Features
- Mockito Object Lifecycle
- Create/Expect Phase
- Replay/Verify Phase
- Mocking Complex Objects
Lesson: Improving Code Quality Through Refactoring
- Refactoring Overview
- Refactoring and Testing
- Refactoring to Design Patterns
- Naming conventions
Session: Appendix
Lesson: Adding Testing to the Build Process
- JUnit and Ant
- The Ant JUnit Tag
- Running JUnit Tests from Ant
- Generating a JUnitReport
Session: Unit Testing using Junit
Lesson: Unit Testing Fundamentals
- Purpose of Unit Testing
- Good Unit Tests
- Test Stages
- Unit Testing Vs Integration Testing
- Understanding Unit Testing Frameworks
Lesson: Jumpstart: JUnit 5.x
- Understand and work with the features of JUnit
- Write unit tests using @Test annotation
- Use @DisplayName to specify a custom name for the test
- Manage fixtures using @BeforeEach, @AfterEach, @BeforeAll and @AfterAll annotations
- Launch tests using @ExtendWith (@RunWith JUnit 4+) annotation
- Build test suites using @SelectPackages or @SelectClasses
- Use @Disabled to prevent a test class or method from running
Lesson: Annotations
- Describe the test execution cycle
- Check for exceptions thrown by test
- Use timeouts to fail test that take longer than required
Lesson: Hamcrest
- Learn the notation of assertThat
- Know the objective of Hamcrest library
- Use Hamcrest's logical and object matchers
- Use Hamcrest's number and collection matchers
Lesson: Parameterized Tests
- The @ParameterizedTest annotation
- A parameterized test to test code under several conditions
- Generic tests to support parameterized testing
Lesson: Advanced Features
- Nested Unit Tests
- Repeated Tests
- JUnit Extensions
- Conditions
- Lambda Support
- Grouped Assertions
Lesson: JUnit Best Practices
- "Good" Tests
- Bad Smell
- White-Box Unit Testing
- Black-Box Unit Testing
- Automation and Coverage
Session: Advanced Topics
Lesson: Mocking of Components
- Why We use Test Dummies
- Mock Objects
- Working with Mock Objects
- Using Mocks with the User Interface
- Mock Object Strategies
Lesson: Mock Objects and Mockito
- Mockito Description and Features
- Mockito Object Lifecycle
- Create/Expect Phase
- Replay/Verify Phase
- Mocking Complex Objects
Lesson: Improving Code Quality Through Refactoring
- Refactoring Overview
- Refactoring and Testing
- Refactoring to Design Patterns
- Naming conventions
Session: Appendix
Lesson: Adding Testing to the Build Process
- JUnit and Ant
- The Ant JUnit Tag
- Running JUnit Tests from Ant
- Generating a JUnitReport
This hands-on course focuses on learning by doing, combining expert lecture, practical demonstrations and group discussions with plenty of machine-based real-world programming labs and exercises. Student machines are required.
This hands-on course focuses on learning by doing, combining expert lecture, practical demonstrations and group discussions with plenty of machine-based real-world programming labs and exercises. Student machines are required.