Unit Testing Essentials Using Junit 5 and Mockito
Total Page:16
File Type:pdf, Size:1020Kb
Trivera Technologies IT Training Coaching Courseware Collaborate. Educate. Accelerate! Unit Testing Essentials using JUnit 5 and Mockito (with Best Practices) Explore Unit Testing, JUnit, Best Practices, Testing Apps with Native IDE Support, Debugging, Using Mockito & More w w w . t r i v e r a t e c h . c o m Course Snapshot Course: Unit Testing Essentials using JUnit 5 and Mockito (TT3526) Duration: 3 days Audience & Skill‐Level: This in an introduction to Unit Testing course for experienced Java developers Language / Tools: This course uses JUnit 5 and Mockito. This course is also available for JUnit 4, or JUnit 5 and EasyMock. Hands‐on Learning: This course is approximately 50% hands‐on, combining expert lecture, real‐world demonstrations and group discussions with machine‐based practical labs and exercises. Student machines are required. Delivery Options: This course is available for onsite private classroom presentation, live online virtual presentation, or can be presented in a flexible blended learning format for combined onsite and remote attendees. Please also ask about our Self‐ Paced / Video or QuickSkills / Short Course options. Public Schedule: This course has active dates on our live‐online open enrollment Public Schedule. Customizable: This course agenda, topics and labs can be further adjusted to target your specific training skills objectives, tools and learning goals. Please inquire for details. Overview 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 JUnit’s strengths and weaknesses. Learning Objectives 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 JUnit’s 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 Trivera Technologies ● IT Training, Coaching & Courseware Solutions www.triveratech.com ● [email protected] ● toll free 844.475.4559 Unit Testing Essentials with JUnit 5 and Mockito ● TT3526 2020 ● Page 1 TDD & Trivera Technologies Unit Testing Collaborative IT Training, Coaching & Courseware Solutions Training Series w w w . t r i v e r a t e c h . c o m ● [email protected] Mockito PowerMock Need different skills or topics? If your team requires different topics or tools, additional skills or custom approach, this course may be further adjusted to accommodate. We offer additional unit testing, TDD, BDD, programming, testing tools, test automation, QA, services, security and other related topics that may be blended with this course for a track that best suits your needs. Our team will collaborate with you to understand your needs and will target the course to focus on your specific learning objectives and goals. Audience & Pre-Requisites This programming course is for experienced Java developers. Take Before: Students should have development skills at least equivalent to the following course(s) or should have attended as a pre‐requisite: TT2104 Core Java Programming for OO Experienced Developers – 4 days Related TDD, JUnit & Unit Testing Courses TT3550 Agile Primer | Understanding Agile Development ‐ An Overview (1 day) TT3530 Understanding Agile Test‐Driven Development (TDD) for Non‐Developers (2 days) TT3555 Understanding BDD, TDD, and Unit Testing | A Technical Overview (1 day) TT3500 Mastering Test‐Driven Development with JUnit (5 days) TT3535‐J Implementing Agile Test‐Driven Development for Java Developers (3 days) TT3525 Unit Testing Essentials using JUnit 5 and EasyMock (3 days) TT3526 Unit Testing Essentials using JUnit 5 and Mockito (3 days) TT3540 Agile Continuous Integration, Testing, and Deployment (CI, Refactoring, GIT, BitBucket & More) (5 days) Follow On Courses: Our TDD and programming tracks include a wide variety of follow‐on courses and learning paths for leveraging Java for next‐level development, testing, security and more. Please see our Java Developer Training Suite & Learning Paths or Testing, TDD, Test Automation & Web Testing Tools (Selenium, Gherkin, Cucumber) Suite of courses, or inquire for recommendations based on your specific role and goals. Enhanced Learning Services: Please also ask about our Pre‐Training Class OnRamp & Prep / Primer offerings, Skills Gap Assessment Services, Case Studies, Knowledge Check Quizzes, Skills Immersion Programs & Camps, Collaborative Mentoring Services and Extended Learning Support & Post Training services. Course Topics / Agenda Please note that this list of topics is based on our standard course offering, evolved from typical industry uses and trends. We’ll work with you to tune this course and level of coverage to target the skills you need most. Topics, agenda and labs are subject to change, and may adjust during live delivery based on audience interests and skill‐level. Session: Unit Testing using JUnit annotation class or method from running Use @DisplayName to specify a Lab: Demo JUnit Lesson: Unit Testing Fundamentals custom name for the test Lab: Build JUnit Case Study Purpose of Unit Testing Manage fixtures using Lab: Jumpstart JUnit Good Unit Tests @BeforeEach, @AfterEach, Lab: Reapplying JUnit Test Stages @BeforeAll and @AfterAll Unit Testing Vs Integration annotations Lesson: Annotations Testing Launch tests using @ExtendWith Describe the test execution cycle Understanding Unit Testing (@RunWith – JUnit 4+) Check for exceptions thrown by Frameworks annotation test Build test suites using Use timeouts to fail test that take Lesson: Jumpstart: JUnit 5.x @SelectPackages or longer than required Understand and work with the @SelectClasses Lab: Working with @Test features of JUnit Use @Disabled to prevent a test Annotation Write unit tests using @Test Trivera Technologies ● IT Training, Coaching & Courseware Solutions www.triveratech.com ● [email protected] ● toll free 844.475.4559 Unit Testing Essentials with JUnit 5 and Mockito ● TT3526 2020 ● Page 2 TDD & Trivera Technologies Unit Testing Collaborative IT Training, Coaching & Courseware Solutions Training Series w w w . t r i v e r a t e c h . c o m ● [email protected] Lesson: Hamcrest Lambda Support Replay/Verify Phase Learn the notation of assertThat Grouped Assertions Mocking Complex Objects Know the objective of Hamcrest Lab: Working with Advanced Lab: Mock Objects and Mockito library Features Lab: Injection Use Hamcrest's logical and object matchers Lesson: JUnit Best Practices Lesson: Improving Code Quality Use Hamcrest's number and "Good" Tests Through Refactoring collection matchers Bad Smell Refactoring Overview Lab: Working with Hamcrest White‐Box Unit Testing Refactoring and Testing Black‐Box Unit Testing Refactoring to Design Patterns Lesson: Parameterized Tests Automation and Coverage Naming conventions The @ParameterizedTest Lab: Refactoring annotation Session: Advanced Topics Lab: Best Practices ‐ Refactoring A parameterized test to test code Tests under several conditions Lesson: Mocking of Components Generic tests to support Why We use Test Dummies Session: Appendix parameterized testing Mock Objects Lab: Working with Parameterized Working with Mock Objects Lesson: Adding Testing to the Build Tests Using Mocks with the User Process Interface JUnit and Ant Lesson: Advanced Features Mock Object Strategies The Ant JUnit Tag Nested Unit Tests Running JUnit Tests from Ant Repeated Tests Lesson: Mock Objects and Mockito Generating a JUnitReport JUnit Extensions Mockito Description and Features Conditions Mockito Object Lifecycle Create/Expect Phase Student Materials: Each student will receive a Student Guide with course notes, code samples, ste‐by‐step written lab instructions for hands‐on work, software tutorials, diagrams and related reference materials and links (as applicable). Students will also receive the