TP3337

Test Driven Development (TDD) and Unit Testing Essentials Training

Explore TDD, Unit Testing, JUnit 5, Best Practices, Database Testing, Refactoring, Mocking, Advanced Features and more in this Test-Driven Development (TDD) and Unit Testing Essentials training course. Throughout the course you'll gain practical experience working with best practices for writing programs in Java using test-driven development techniques. Attendees leave this course equipped with the skills required to leverage solid test driven development and unit testing techniques. 
Course Details

Duration

3 days

Prerequisites

Java development experience is recommended.

Target Audience

  • Software Developers and Programmers
  • Agile Practitioners
  • Quality Assurance Professionals
  • Software Testers
  • Product Owners
  • Project Managers
  • IT Manager
  • Software Engineers

Skills Gained

  • Understand the role of Unit Testing in software development and testing
  • Wrtie effective Unit Testing
  • Incorporate properties of effective unit tests
  • Understand the benefits of the test-first and Test-Driven Development
  • Apply techniques and practices to aid in the successful adoption of Test-Driven Development
  • Work with the JUnit and the JUnit Test Runner interface
  • Use JUnit to drive the implementation of Java code
  • Debug in conjunction with tests
  • Understand the fundamentals of the TDD using Java, as well as its importance, uses, strengths and weaknesses.
  • Understand how JUnit affects your perspective on development and increases your focus on a task.
  • Code JUnit using best practices
  • Create well-structured JUnit programs
  • Compile and execute programs using JUnit and DBUnit
  • Extend testing with mock objects using Mockito
  • Use refactoring techniques available to make code as reusable/robust as possible.
  • Apply various testing techniques
Course Outline
  • Introducing Test-driven Development 
    • Test-Driven Development
      • Rationale for TDD
      • The process of TDD
      • Advantages to TDD
      • Side-effects of TDD
      • Tools to support TDD
      • Setup IntelliJ for Using Maven
  • Unit Testing using JUnit 
    • Unit Testing Fundamentals
      • Purpose of Unit Testing
      • Good Unit Tests
      • Test Stages
      • Unit Testing Vs Integration Testing
      • Understanding Unit Testing Frameworks
    • Jumpstart: JUnit 5.x
      • Understand and work with the features of JUnit
      • Write unit tests using @Test annotation
      • Test Result Verification (Assertions)
      • Manage fixtures using @BeforeEach, @AfterEach, @BeforeAll and @AfterAll annotations
      • Maven setup using Surefire plugin
    • Annotations
      • Use @DisplayName to specify a custom name for the test
      • Check for exceptions thrown by test
      • Use @Disabled to prevent a test class or method from running
      • Use timeouts to fail test that take longer than required
      • Test Execution Order
    • 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
    • Parameterized Tests
      • The @ParameterizedTest annotation
      • A parameterized test to test code under several conditions
      • Define different sources for test data (@ValueSource, @CsvSource, @CsvFileSource,@EnumSource, @MethodSource, @ArgumentSource)
    • Advanced Features
      • JUnit 4 vs JUnit 5
      • Nested Unit Tests
      • Repeated Tests
      • JUnit Extensions
      • ExecutionConditions
      • Lambda Support
      • Grouped Assertions
    • JUnit Best Practices
      • \"Good\" Tests
      • Bad Smell
      • White-Box Unit Testing
      • Black-Box Unit Testing
      • Automation and Coverage
  • Mocking 
    • Mocking of Components
      • Why We use Test Dummies
      • Working with Mock Objects
      • Using Mocks with the User Interface
      • Mock Object Strategies
    • Mock Objects and Mockito
      • Mockito Description and Features
      • Mockito Object Lifecycle
      • JUnit 5 and Mockito Dependency Injection
      • Stubs Using ArgumentMatchers
      • Verifying Behavior in Mockito
      • Partial Mock Objects
      • The Spy annotation
    • PowerMock
      • PowerMock Description and Features
      • Using PowerMockito
      • @PrepareForTest
      • Mocking a final class or final method
      • Mocking a Static Method
  • Advanced Topics 
    • State-based vs. Interaction-based Testing
      • State-based Testing
      • Interaction-based Testing
      • Mock Objects Support Each Approach
      • Three Areas to Check in a Test
    • Improving Code Quality Through Refactoring
      • Refactoring Overview
      • Refactoring and Testing
      • Refactoring to Design Patterns
      • Lab: Refactoring
    • Database Testing: DbUnit
      • Setting up DbUnit
      • Defining a Dataset File in XML, CSV or Excel
      • Writing a DbUnit Test Class
      • Assert the results
      • Use the FailureHandler and ValueComparer
      • Using Date and Time in test sets
      • Export a data set
    • Conclusion