Software testing fundamentals
Fundamentals of software testing from a technical point of view
Software testing is an area in software development and engineering that has not been accorded enough attention, even among top developers and engineers. Especially because every developer or engineer believes they know something about it, or simply don’t see much value in it. And even more so, because engineers overtly trust too much in their expertise and ability to churn out correct and error-free pieces of software. Which in most cases is wrong.
This article will walk you through the fundamentals of software testing that every software engineer or developer should be acquainted with. It follows a synoptic and conceptual approach. Let’s get started.
What is Software Testing?
Software testing is a method and process in software development, of comparing actual software with set requirements, before delivery to end users. It is a way of ensuring the software functions as intended by the builders(developers); and in subsequent upgrades of the software, existing functionalities don’t break (regress) and expectations will remain the same.
Why should we bother testing code (software):
The essence of writing any piece of software is to solve a problem and give satisfaction to the users. But if the software doesn’t work as intended by the builders, due to errors or bugs in the code, then the purpose of the software is defeated (lost) and users would be unsatisfied.
If these errors and bugs(defects) can be detected early during development, before delivery of the piece of software to final users, then the cost of delivering defective software, the time needed to fix the defects, the trust deficit that would accrue due to delivery of a defective product (software) which in most cases are enormous, could be all-together avoided.
This is where writing good and quality tests could come to the rescue.
What are the common types of testing?
We have 3 common types of testing:
(1) Functional testing
We also have various types of functional testing, among which are:
(a) Unit testing — Tests single units of an application (each component) to ensure they function intended.
(b) Integration testing — Tests an aggregation of units (components) to ensure they function together as intended.
(c) System(End to end/E2E) testing — Tests an entire system or application ensuring it functions as intended in a real-world situation.
(2) Non-functional testing
We also have various types of non-functional testing, among which are:
(a) Performance testing — Testing the adherence of an application to specific performance requirements.
(b) Accessibility testing — Testing the usability of an application by people with some disabilities or by users who rely on screen readers.
(3) Regression (Maintenance testing)
This is testing carried out to discover or find errors or bugs after changes have been made to a piece of software or code base. The changes could be an introduction of a feature or fixing of a defect or bug that leads to the breaking of another existing functionality or feature.
Importance of Writing Good (Quality) tests:
(1) It enhances code maintainability, providing a guide to you in the future and future colleagues on the expected behavior of the application (code). Also, enabling the adding and removal of features without breaking existing code (expected behavior of application).
(2) Confidence to developers that a given application will function as intended.
(3) Documentation of expected/intended behavior of an application (code). Especially since a feature can be implemented in several ways.
(4) Debugging purposes and early discovery of defects(bugs). It prevents code regression and ensures products are not delivered broken even within a tight schedule.
Is Testing, rather not the same as Debugging?
Testing aims to enforce that a given code (a piece of software) does, what it says it does; in other words, meets its behavioral expectations. Thus, in this way, it proactively uncovers errors or debugs that threaten the accomplishment of its desired or expected behavior. Testing, ordinarily is not set out primarily to find or discover bugs or defects in a given piece of software, but testing asserts behavioral expectations or expected outcomes from the piece of software.
Whereas, on the other hand, Debugging comes into play when testing, code review, or some other method has revealed a defect or bug in the piece of software (code). Hence, debugging is a process encompassing means and methods of discovering the root cause of a bug(defect) and correcting(fixing) it in line with the expected behavior of the software.
Debugging involves using several methods, such as:
(1) Logging: Printing parts of the code to the console, ensuring the code executes as expected, and returns appropriate values.
(2) Code debuggers and debugging extensions: Special tools used to step through lines of code, inspecting variables and their values.
(3) Manual code inspection and code reviewing
Consequences of Lack of Software Testing
The results of a lack of testing could be severe. Examples of such consequences are:
(1) It could lead to a bad user experience.
(2) Create trust deficiency with customers (end-users) of the product.
(3) It could lead to loss of revenue.
(4) It could cause reputational damage for the company.
(5) It could lead to costly recalls of products, such as Tesla 135, 000 vehicles recall due to Memory Failure.
(6) It could even lead to deadly consequences, such as Airbus A400M plane crash.
Testing approaches for Software delivery
Due to the wide adoption and evolution of Agile methodologies over the years for software delivery, testing approaches have become ingrained in successful development practices for speedy and efficient software delivery. This is all the more so since Agile Development Practices encourage prompt and timely feedback mechanisms and fast-track product delivery. Among such development practices are:
(1) Test Driven Development (TDD)
(2) Behaviour Driven Development (BDD)
(3) Acceptance Test Driven Development (ATDD)
TDD
TDD as a software development practice, is a test-first approach. It is an iterative process, that involves three (3) steps:
(1) it starts with writing tests for features to be built, which fails initially.
(2) Chunks of codes (pieces of software) are developed, and refined until the tests pass.
(3) Subsequently, the pieces of software are refactored and optimized in line with best practices and software behavior.
The benefits of TDD are:
(1) It leads to the creation of an optimum product (from an engineering perspective).
(2) It creates a piece of software with high test coverage that is very maintainable.
The short-falls of TDD are:
(1) It focuses too much on implementation and tests are mainly understood by the developers.
(2) It does not foster much collaboration among various stakeholders such as customers, product owners, developers, etc.
(3) It adds complexity and too much overhead to the development process and bulky tests.
BDD
BDD as a software development practice, is a test-first approach, like TDD. Unlike TDD, which focuses on implementation and thus enjoys high test coverage, BDD focuses on defining the behavior of software (application) along the lines of the expectations of the business stakeholders and end users.
The benefits of BDD are:
(1) Tests are written in plain language that communicates the business expectation of the product.
(2) It fosters collaboration among stakeholders, especially in a way not present in TDD in the product development process.
(3) Emphasis is moved away from testing the implementation of the product to testing the actual and expected behavior of the software.
The short-falls of BDD are:
(1) A lot of delay in the development process due to the need for constant and excessive meetings and collaboration among stakeholders.
(2) Requires a lot of documentation of requirements from business and other stakeholders.
ATDD
ATDD as a software development practice, is a test-first approach, also. It emphasizes collaboration among stakeholders to ensure a given software complies with set and predefined acceptance criteria(acceptance tests are written). It focuses on the software complying with requirements set by the business and other stakeholders.
The benefits of ATDD are:
(1) Acceptance tests are written in plain language to capture the set requirements.
(2) It fosters collaboration among stakeholders in the product development process.
(3) It moves away from the implementation and the behavior of the software (product) to the development of software that meets precise users’ requirements.
The short-falls of ATDD are:
(1) The process of drafting the requirements could be flawed.
(2) Requires meticulous preparation and documentation of the acceptance criteria, which eventually becomes the basis for testing.
Hope you’ve found this useful! Let me know if you have any questions, or found something(s) I missed!