Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

readme.md

Overview

Introduction

Writing test cases for your code ensures code quality, proper implementation of business logic, and easy refactoring. It is an essential part of the development process.

Basic TDD Workflow

  1. Write a Test: Define the desired functionality.
  2. Run the Test: Ensure it fails (since the functionality is not yet implemented).
  3. Write Code: Implement the minimum code required to pass the test.
  4. Run Tests: Verify that all tests pass.
  5. Refactor: Improve the code structure while ensuring that tests still pass.
  6. Repeat: Continue this process for each new feature.

TDD Libraries


The following libraries are used for TDD. All methods and features of these libraries are available for writing test cases:

How to Run


You can run the test cases from the plugin's root directory terminal using one of the following methods:

Option 1:

Run tests using the ./vendor/bin/phpunit command:

./vendor/bin/phpunit
./vendor/bin/phpunit --filter {your-filter-key}

Option 2:

Use the custom commands test and test-f added to the composer script:

composer test
composer test-f {your-filter-key}

Why Not Latest PHPUnit

We can only use PHPUnit versions that are supported by WP PHPUnit.