Nov '23

In 2023 there really is no excuse to be ignoring unit testing in your applications. When coming in to auditing a development project, my first question is always “What’s the testing strategy?”. More often than not the answer comes in as 10-20% unit test coverage, and that’s about it. Almost as often, when I come to look at the “unit tests” I find a lovely folder full of integration tests!

Now integration tests are very useful, don’t get me wrong, but they should not be the foundation of your testing strategy. Unit tests are there to test the most simple components within your codebase (usually down to individual function level), whereas Integration tests exist to test the interoperability of sections of these units.

Some programming frameworks make it virtually impossible to produce clean unit tests (**cough** Magento **cough**) but if your testing doesn’t being with the smallest practicable components of functionality then the rest of your strategy will be built on seriously unstable foundations.

Unit testing and integration testing are two distinct levels of software testing, each serving specific purposes in the software development life cycle. To clarify this distinction, here is a comparison between unit testing and integration testing:


  • Unit Testing: Focuses on testing individual units or components of a system in isolation. A unit is the smallest testable part of an application, such as a function or a method.
  • Integration Testing: Involves testing the interactions and interfaces between integrated components or systems. It ensures that the combined units function correctly as a group.


  • Unit Testing: Aims to validate that each unit of the software performs as designed. It helps identify and fix bugs at an early stage of development and provides a foundation for higher-level testing.
  • Integration Testing: Verifies the correct interactions between integrated components and detects issues related to the interfaces and data flow between them.


  • Unit Testing: Isolates individual units from the rest of the application, often through the use of mocks or stubs to simulate dependencies.
  • Integration Testing: Involves the collaboration of multiple units or components, checking how they work together and share data.


  • Unit Testing: Typically, dependencies are mocked or stubbed to isolate the unit under test. External systems or components are not involved.
  • Integration Testing: Involves real interactions between integrated components, including their dependencies on external systems, databases, or services.

Execution Speed

  • Unit Testing: Tends to be faster since it deals with small, isolated units of code.
  • Integration Testing: May take longer due to the need to set up and coordinate multiple components.

Feedback Loop

  • Unit Testing: Provides fast feedback to developers during the coding phase, enabling them to catch and fix issues early.
  • Integration Testing: Provides feedback on how different components work together, ensuring that the integration is correct and identifying issues that may arise when combining units.

Testing Levels

  • Unit Testing: A lower-level testing activity focused on the smallest parts of the software.
  • Integration Testing: A higher-level testing activity that comes after unit testing and before system testing.


  • Unit Testing: Highly automated, with tools and frameworks designed specifically for unit testing.
  • Integration Testing: Also automated, but may involve more complex setups and configurations, as it deals with multiple integrated components.

In practice, a comprehensive testing strategy should include both unit testing and integration testing to ensure the reliability and functionality of the entire system. Unit testing catches issues at the individual component level, while integration testing ensures that these components work seamlessly together.

Sep '23

Behavior-Driven Development (BDD) and Test-Driven Development (TDD) are two methodologies that emphasize testing throughout the software development process. While they share common principles, they have distinct focuses and approaches. Here’s a comparison between BDD and TDD:


  • TDD: Primarily focuses on writing tests for individual units of code before the actual implementation. The focus is on validating the correctness of code at a granular level.
  • BDD: Shifts the focus from testing to the behavior of the system as a whole. It emphasizes collaboration between technical and non-technical stakeholders to define and understand the expected behavior of the system.


  • TDD: Tests are written using the programming language of the application, often closely tied to the implementation details. The language is technical and geared towards developers.
  • BDD: Uses a natural language specification, often written in the Given-When-Then format. This language is more accessible to non-technical stakeholders and encourages collaboration between different roles in the team.

Stakeholders Involvement

  • TDD: Primarily involves developers and testers. Tests are written to ensure that the code meets specified requirements and functions correctly.
  • BDD: Involves a broader range of stakeholders, including non-technical team members such as product owners and business analysts. Scenarios are often written collaboratively to capture the expected behavior of the system.


  • TDD: Aims to ensure that individual units of code are correct, maintainable, and well-designed. It follows the “Red-Green-Refactor” cycle to incrementally build the application.
  • BDD: Aims to ensure that the software behaves as expected from a business perspective. It helps bridge the communication gap between technical and non-technical stakeholders by using natural language specifications.

Levels of Abstraction

  • TDD: Works at a lower level of abstraction, focusing on the details of individual units or components of code.
  • BDD: Works at a higher level of abstraction, focusing on the overall behavior of the system and its interactions with external components.


  • TDD: Highly automated, with a strong emphasis on automated unit tests that developers write to validate their code.
  • BDD: Also involves automation, but the emphasis is on automating high-level acceptance tests derived from the natural language specifications.


  • TDD: Primarily concerned with unit testing, with the possibility of integration testing as well.
  • BDD: Encompasses higher-level acceptance testing, which may involve testing the integration of multiple components to ensure that they collectively deliver the desired behavior.


  • TDD: Utilizes testing frameworks specific to the programming language being used.
  • BDD: Often uses BDD frameworks and tools that support the Given-When-Then syntax, such as Cucumber, Behave, or SpecFlow.

In practice, these methodologies are not mutually exclusive, and teams often use them in conjunction. TDD can be employed for unit testing within the BDD framework, ensuring that individual units of code are well-tested while BDD scenarios capture and verify the overall behavior of the system.