FACTOID # 68: Canada lays claim to more water than any other nation.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

FACTS & STATISTICS    Simple view

  1. Select countries to view: (hold down Control key and click to select several)

     

     

    Compare:

     

     

  1. Select fact or statistic: (* = graphable)

     

     

     

  2. (OPTIONAL) Compare to statistic: (both need to be graphable)

     

     

     

  3. View result as:

     

       
(OR) SEARCH ALL encyclopedia, stats & forums:   

Encyclopedia > Unit test

In computer programming, a unit test is a procedure used to validate that a particular module of source code is working properly. Ideally, each test case is separate from the others; constructs such as mock objects can assist in separating unit tests. This type of testing is mostly done by the developers and not by end-users. Computer programming (often simply programming or coding) is the craft of writing a set of commands or instructions that can later be compiled and/or interpreted and then inherently transformed to an executable that an electronic machine can execute or run. Programming requires mainly logic, but has elements of science... This article or section is missing references or citation of sources. ... Source code (commonly just source or code) is any series of statements written in some human-readable computer programming language. ... In software engineering, a test case is a set of conditions or variables under which a tester will determine if a requirement upon an application is partially or fully satisfied. ... Mock objects are simulated objects that mimic the behavior of real objects in controlled ways. ... A software developer is a programmer who is concerned with one or more facets of the software development process, a somewhat broader scope of computer programming. ... Economics and commerce define an end-user as the person who uses a product. ...

Contents

Benefit

The goal of unit testing is to isolate each part of the program and show that the individual parts are correct. Unit testing provides a strict, written contract that the piece of code must satisfy. As a result, it affords several benefits.


Facilitates change

Unit testing allows the programmer to refactor code at a later date, and make sure the module still works correctly (i.e. regression testing). The procedure is to write test cases for all functions and methods so that whenever a change causes a regression, it can be quickly identified and fixed. This provides the benefit of encouraging programmers to make changes to the code since it is easy for the programmer to check if the piece is still working properly. Good unit test design produces test cases that cover all paths through the unit with attention paid to loop conditions. Refactoring is the process of rewriting a computer program or other material to improve its structure or readability, while explicitly keeping its meaning or behavior. ... Regression testing is any type of software testing which seeks to uncover regression bugs. ... In computer science, a subroutine (function, method, procedure, or subprogram) is a portion of code within a larger program, which performs a specific task and is relatively independent of the remaining code. ... Used mainly in object-oriented programming, the term method refers to a piece of code that is exclusively associated either with a class (called class methods, static methods, or factory methods) or with an object (called instance methods). ... Code coverage is a measure used in software testing. ...


In continuous unit testing environments, through the inherent practice of sustained maintenance, unit tests will continue to accurately reflect the intended use of the executable and code in the face of any change. Depending upon established development practices and unit test coverage, up-to-the-second accuracy can be maintained.


Simplifies integration

Unit testing helps to eliminate uncertainty in the units themselves and can be used in a bottom-up testing style approach. By testing the parts of a program first and then testing the sum of its parts, integration testing becomes much easier. Top-down and bottom-up are strategies of information processing and knowledge ordering, mostly involving software, and by extension other humanistic and scientific system theories (see systemics). ... Integration testing (sometimes called Integration and testing and abbreviated I&T) is the phase of software testing in which individual software modules are combined and tested as a group. ...


A heavily debated matter exists in assessing the need to perform manual integration testing. While an elaborate hierarchy of unit tests may seem to have achieved integration testing, this presents a false sense of confidence since integration testing evaluates many other objectives that can only be proven through the human factor. Some argue that given a sufficient variety of test automation systems, integration testing by a human test group is unnecessary. Realistically, the actual need will ultimately depend upon the characteristics of the product being developed and its intended uses.


Documentation

Unit testing provides a sort of "living document". Clients and other developers looking to learn how to use the module can look at the unit tests to determine how to use the module to fit their needs and gain a basic understanding of the API. To meet Wikipedias quality standards, this article or section may require cleanup. ...


Unit test cases embody characteristics that are critical to the success of the unit. These characteristics can indicate appropriate/inappropriate use of a unit as well as negative behaviors that are to be trapped by the unit. A unit test case, in and of itself, documents these critical characteristics, although many software development environments do not rely solely upon code to document the product in development. In software engineering, a test case is a set of conditions or variables under which a tester will determine if a requirement upon an application is partially or fully satisfied. ...


Ordinary documentation, on the other hand, is more susceptible to drifting from the implementation of the program and will thus become outdated (e.g. design changes, feature creep, relaxed practices to keep documents up to date).


Separation of interface from implementation

Because some classes may have references to other classes, testing a class can frequently spill over into testing another class. A common example of this is classes that depend on a database: in order to test the class, the tester often writes code that interacts with the database. This is a mistake, because a unit test should never go outside of its own class boundary. As a result, the software developer abstracts an interface around the database connection, and then implements that interface with their own mock object. This results in loosely coupled code, minimizing dependencies in the system. This article discusses a general notion of reference in computing. ... The term database originated within the computer industry, though its meaning has been broadened by popular use,includes non-electronic databases within its definition. ... Mock objects are simulated objects that mimic the behavior of real objects in controlled ways. ... Loosely coupled describes a resilient relationship between two or more computer systems that are exchanging data. ...


Limitations of unit testing

Unit-testing will not catch every error in the program. By definition, it only tests the functionality of the units themselves. Therefore, it will not catch integration errors, performance problems or any other system-wide issues. In addition, it may not be easy to anticipate all special cases of input the program unit under study may receive in reality. Unit testing is only effective if it is used in conjunction with other software testing activities. In software engineering, performance testing is testing that is performed to determine how fast some aspect of a system performs under a particular workload. ... Software testing is the process used to help identify the correctness, completeness, security, and quality of developed computer software. ...


It is unrealistic to test all possible input combinations for any non-trivial piece of software. A unit test can only show the presence of errors; it cannot show the absence of errors. Though these two limitations apply to any form of software test.


Applications

Extreme Programming

The cornerstone of Extreme Programming (XP) is the unit test. XP relies on an automated unit test framework. This automated unit test framework can be either third party, e.g. xUnit, or created within the development group. Extreme Programming (XP) is a software engineering methodology, the most prominent of several agile software development methodologies. ... Various code-driven testing frameworks have come to be known collectively as xUnit. ...


Extreme Programming uses the creation of unit tests for Test Driven Development. The developer writes a unit test that exposes either a software requirement or a defect. This test will fail because either the requirement isn't implemented yet, or because it intentionally exposes a defect in the existing code. Then, the developer writes the simplest code to make the test, along with other tests, pass. Test-driven development (TDD) is a programming technique heavily emphasized in Extreme Programming. ...


All classes in the system are unit tested. Developers release unit test code to the code repository in conjunction with the code it tests. XP's thorough unit testing allows the benefits mentioned above, such as simpler and more confident code development and refactoring, simplified code integration, accurate documentation, and more modular designs. These unit tests are also constantly run as a form of regression test. Regression testing is any type of software testing which seeks to uncover regression bugs. ...


Techniques

Unit testing is commonly automated, but may still be performed manually. As with many reputable standards bodies, the IEEE[1] prescribes neither an automated nor a manual approach. A manual approach to unit testing may employ a step-by-step instructional document. Nevertheless, the objective in unit testing is to isolate a unit and validate its correctness. Automation is very efficient for achieving this, and enables the many benefits listed in this article. Conversely, if not planned carefully, a careless manual unit test case may execute as an integration test case (involving many software components), thus precluding the achievement of most (if not all) of the goals established for unit testing. Test automation is the use of software to control the execution of tests, the comparison of actual outcomes to predicted outcomes, the setting up of test preconditions, and other test control and test reporting functions. ... The Institute of Electrical and Electronics Engineers or IEEE (pronounced as eye-triple-e) is an international non-profit, professional organization for the advancement of technology related to electricity. ...


Under the automated approach, to fully realize the effect of isolation, the unit or code body subjected to the unit test is executed within a framework outside of its natural environment, that is, outside of the product or calling context for which it was originally created. Testing in an isolated manner has the benefit of revealing unnecessary dependencies between the code being tested and other units or data spaces in the product. These dependencies can then be eliminated through refactoring, or if necessary, re-design. The following is a list of unit testing frameworks for various programming languages. ... Refactoring is the process of rewriting a computer program or other material to improve its structure or readability, while explicitly keeping its meaning or behavior. ...


Using a unit testing framework, the developer codifies criteria into the unit test to verify the correctness of the unit under test. During execution of the unit test(s), the framework logs test cases that fail any criterion. Many frameworks will also automatically flag and report in a summary these failed test cases. Depending upon the severity of a failure, the framework may halt subsequent testing.


As a consequence, unit testing is traditionally a motivator for programmers to create decoupled and cohesive code bodies. This practice promotes healthy habits in software development. Design patterns, unit testing, and refactoring often work together so that the most ideal solution may emerge. In computer science, coupling or dependency is the degree to which each program module relies on each other module. ... In computer programming, cohesion is a measure of how well the lines of source code within a module work together to provide a specific piece of functionality. ... {{Hide = {{{ Hybrid reference style allows grouped references at top, but uses m:Cite. ...


Language support

The D programming language offers direct support for unit testing. D is an object-oriented, imperative system programming language designed by Walter Bright of Digital Mars as a re-engineering of C/C++. He has done this by re-designing many C++ features, and borrowing ideas from other programming languages. ...


Unit testing frameworks, which help simplify the process of unit testing, have been developed for a wide variety of languages. The following is a list of unit testing frameworks for various programming languages. ...


See also

Software testing is the process used to help identify the correctness, completeness, security, and quality of developed computer software. ... Integration testing (sometimes called Integration and testing and abbreviated I&T) is the phase of software testing in which individual software modules are combined and tested as a group. ... According to the IEEE Standard Computer Dictionary, System testing is testing conducted on a complete, integrated system to evaluate the systems compliance with its specified requirements. ... Test-Driven Development (TDD) is a computer programming technique that involves repeatedly first writing a test case and then implementing only the code necessary to pass the test. ... Extreme Programming (XP) is a software engineering methodology, the most prominent of several agile software development methodologies. ... Regression testing is any type of software testing which seeks to uncover regression bugs. ... In software engineering, a test case is a set of conditions or variables under which a tester will determine if a requirement upon an application is partially or fully satisfied. ... The following is a list of unit testing frameworks for various programming languages. ... In software engineering, software testing automated testing is that which is performed, to a greater or lesser extent, by a computer. ...

References

  1. ^ IEEE Standards Board, "IEEE Standard for Software Unit Testing: An American National Standard, ANSI/IEEE Std 1008-1987" in IEEE Standards: Software Engineering, Volume Two: Process Standards; 1999 Edition; published by The Institute of Electrical and Electronics Engineers, Inc. Software Engineering Technical Committee of the IEEE Computer Society.

External links

  • Kent Beck's original testing framework paper
  • List of articles on unit testing

  Results from FactBites:
 
Unit test - Wikipedia, the free encyclopedia (1355 words)
Unit testing helps to eliminate uncertainty in the units themselves and can be used in a bottom-up testing style approach.
Unit test cases embody characteristics that are critical to the success of the unit.
Unit testing frameworks, which help simplify the process of unit testing, have been developed for a wide variety of languages.
23.3 unittest -- Unit testing framework (448 words)
The Python unit testing framework, sometimes referred to as ``PyUnit,'' is a Python language version of JUnit, by Kent Beck and Erich Gamma.
When the test is run, the fixture initialization is run first; if it succeeds, the cleanup method is run after the test has been executed, regardless of the outcome of the test.
This class allows individual tests and test suites to be aggregated; when the suite is executed, all tests added directly to the suite and in ``child'' test suites are run.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.