Unit testing

Unit testing is an important early step in software development and testing. Categorized as a functional, white-box testing method, unit testing occurs first in the four-step process of testing software to ensure it meets specifications and works properly. In unit testing, developers or other testers isolate small parts, or units, of a piece of software. Either using manual or automated methods, the testers then evaluate whether each unit works correctly. If the unit passes the tests, it is subjected to further levels of testing, usually in integration with other, related units. These tests allow for a step-by-step development of a finished, and ideally error-free, piece of software.rssalemscience-20190201-43-174181.jpgrssalemscience-20190201-43-174247.jpg

Background

In the twenty-first century, computers affect a tremendous amount of human activity. Software, or programs that give instructions to computers and allow them to perform specific tasks, is necessary to make electronic devices work efficiently and effectively. For that reason, software development and testing are crucially important tasks in the modern world.

Software testing is the process of checking whether a piece of software is operating as intended and making sure the software is free of defects. Software testers run software and check all of its functions on many levels. They often separate software into its component systems and processes and check them individually. This careful scrutiny can identify any missing information, errors, or other shortcomings before the software is finished and released.

A lack of proper software testing can lead to faulty programs and malfunctioning devices. The effects of these errors range from the inconvenient to the catastrophic. Program errors can occur in cars and airplanes, seriously endangering their operators and passengers. Errors can also occur in financial software and business systems, leading to mass confusion and sometimes enormous losses of money.

The importance of software testing is only matched by its complexity. Each type of software may require a unique approach to testing, both during development and after production. Generally, software testing can be categorized in three ways. First, functional testing ensures that all the capabilities of a piece of software meet given specifications. Second, non-functional testing deals with overall performance factors of the software. Third, maintenance testing deals with how well the software works over time and whether it requires updating or repair.

Software testing is also divided into two other broad categories. These are known as black-box testing and white-box testing. In black-box testing, testers are unfamiliar with the internal workings of the software or device they are testing. In white-box testing, testers are familiar with how the software or devices being tested work internally. These different approaches have an important effect on how a tester prepares for and conducts a test.

Overview

One method of functional testing that falls into the white-box category is known as unit testing. Unit testing is one of the most important and fundamental aspects of software development and testing. Generally, unit testing means that testers explore and evaluate the individual parts of a given piece of software. A tester will isolate various small parts, or units, of a program and ensure that they are correct in their coding and functioning.

Unit testing may be done manually or through automated processes. When performed manually, unit testing is usually conducted by the person or people who developed the software, or by their associates. These testers may use special frameworks, guidelines, and tools such as drivers. A driver is software that allows a piece of hardware to communicate with the operating system of a computer. One challenge for testers is isolating specific units within a program, which might require the use of stubs or mock objects to represent the structure of the rest of the program.

Most developers opt to use automated unit testing. In doing so, the developer uses a special testing application. After the developer enters the code of the unit to be tested, the application runs automated test cases to evaluate the code under different circumstances. The number of tests required is based on the complexity and intended functions of the unit. Ideally, the unit will pass each test case, but in the event of failure, the application creates a log of errors and descriptions.

Developers use unit testing as a first level in a four-step process of software testing. After the individual units pass their test, the software moves to integration testing, which evaluates how units work when combined into groups. Groups that interact correctly then move along to system testing, which evaluates the functions of the combined system of software toward its intended goals. Finally, the software moves to acceptance testing, the last stage, which determines whether the software is ready to be distributed and used by consumers.

Unit testing is an advantageous step in software development for many reasons. Primarily, unit testing allows developers to identify and correct bugs, or error-causing problems, in software at an early point in development. Missing these bugs and allowing faulty software to be produced could lead to problems, delays, and further expenses. Unit testing helps developers learn about and become comfortable with the internal functions of their software, and helps them document the steps and quality checks involved in the development process. Unit testing also allows developers to easily reuse some of their software code in future products.

Developers may use a wide variety of tools and programs to perform a unit test. They must choose the best tools based on the kind of unit being tested and the overall compatibility requirements of the system. Some popular testing tools include JMockit, which offers code coverage and metrics for lines and paths; NUnit, a framework that allows manual writing of scripts; and EMMA, a tool specially created for the Java programming language. Other tools include Jtest, Junit, and PHPUnit.

Bibliography

McFarlin, Tom. “The Beginner’s Guide to Unit Testing: What Is Unit Testing?” Envato Tuts+, 19 June 2012, code.tutsplus.com/articles/the-beginners-guide-to-unit-testing-what-is-unit-testing--wp-25728. Accessed 18 June 2019.

Rouse, Margaret. “Unit Testing.” TechTarget, 2019, searchsoftwarequality.techtarget.com/definition/unit-testing. Accessed 18 June 2019.

“Software Testing Levels.” Software Testing Fundamentals, 2019, softwaretestingfundamentals.com/software-testing-levels/. Accessed 18 June 2019.

“Unit Testing.” Software Testing Fundamentals, 2019, softwaretestingfundamentals.com/unit-testing/. Accessed 18 June 2019.

“Unit Testing Tutorial: What is, Types, Tools, EXAMPLE.” Guru99, 2019, www.guru99.com/unit-testing-guide.html. Accessed 18 June 2019.

Wells, Don. “Unit Tests.” Extreme Programming, 1999, www.extremeprogramming.org/rules/unittests.html. Accessed 18 June 2019.

“What is Software Testing? Introduction, Definition, Basics & Types.” Guru99, 2019, www.guru99.com/software-testing-introduction-importance.html. Accessed 18 June 2019.

“What is Unit Testing?” SmartBear Software, 2019, smartbear.com/learn/automated-testing/what-is-unit-testing/. Accessed 18 June 2019.