xUnit is the collective name for several
unit testing frameworks that derive their structure and functionality from
Smalltalk
Smalltalk is an object-oriented, dynamically typed reflective programming language. It was designed and created in part for educational use, specifically for constructionist learning, at the Learning Research Group (LRG) of Xerox PARC by ...
's
SUnit SUnit is a unit testing framework for the programming language Smalltalk. It is the original source of the xUnit design, originally written by one of the creators of Extreme Programming, Kent Beck
Kent Beck (born 1961) is an American software en ...
. ''SUnit'', designed by
Kent Beck in 1998, was written in a highly structured
object-oriented
Object-oriented programming (OOP) is a programming paradigm based on the concept of " objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of ...
style, which lent easily to contemporary languages such as
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
and
C#. Following its introduction in Smalltalk the framework was
ported to Java by
Kent Beck and
Erich Gamma and gained wide popularity, eventually gaining ground in the majority of programming languages in current use. The names of many of these frameworks are a variation on "SUnit", usually replacing the "S" with the first letter (or letters) in the name of their intended language ("
JUnit" for
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
, "
RUnit
runit is an init and service management scheme for Unix-like operating systems that initializes, supervises, and ends processes throughout the operating system. Runit is a reimplementation of the daemontools process supervision toolkit that ...
" for
R etc.). These frameworks and their common architecture are collectively known as "xUnit".
xUnit architecture
All xUnit frameworks share the following basic component architecture, with some varied implementation details.
Test runner
A
test runner
Test(s), testing, or TEST may refer to:
* Test (assessment), an educational assessment intended to measure the respondents' knowledge or other abilities
Arts and entertainment
* ''Test'' (2013 film), an American film
* ''Test'' (2014 film), ...
is an executable program that runs tests implemented using an xUnit framework and reports the test results.
[Meszaros, Gerard (2007) ''xUnit Test Patterns'', Pearson Education, Inc./Addison Wesley]
Test case
A
test case
In software engineering, a test case is a specification of the inputs, execution conditions, testing procedure, and expected results that define a single test to be executed to achieve a particular software testing objective, such as to exercise ...
is the most elemental class. All unit tests are inherited from here.
Test fixtures
A
test fixture (also known as a test context) is the set of
preconditions or state needed to run a test. The developer should set up a known good state before the tests, and return to the original state after the tests.
Test suites
A
test suite is a set of tests that all share the same fixture. The order of the tests shouldn't matter.
Test execution
The execution of an individual unit test proceeds as follows:
setup(); /* First, we should prepare our 'world' to make an isolated environment for testing */
...
/* Body of test - Here we make all the tests */
...
teardown(); /* At the end, whether we succeed or fail, we should clean up our 'world' to
not disturb other tests or code */
The setup() and teardown() methods serve to initialize and clean up test fixtures.
Test result formatter
A
test runner
Test(s), testing, or TEST may refer to:
* Test (assessment), an educational assessment intended to measure the respondents' knowledge or other abilities
Arts and entertainment
* ''Test'' (2013 film), an American film
* ''Test'' (2014 film), ...
produces results in one or more output formats. In addition to a plain, human-readable format, there is often a test result formatter that produces
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. ...
output. The
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. ...
test result format originated with
JUnit but is also used by some other xUnit testing frameworks, for instance build tools such as
Jenkins
Jenkins may refer to:
People
* Jenkins (name), history of the surname
* List of people with surname Jenkins
* The Jenkins, country music group
Places United States
*Jenkins, Illinois
*Jenkins, Kentucky
*Jenkins, Minnesota
*Jenkins, Missouri
*Je ...
and
Atlassian Bamboo.
Assertions
An
assertion is a function or macro that verifies the behavior (or the state) of the unit under test. Usually an assertion expresses a
logical condition that is true for results expected in a correctly running
system under test (SUT).
Failure of an assertion typically throws an
exception, aborting the execution of the current test.
xUnit frameworks
Many xUnit frameworks exist for various programming languages and development platforms.
*
List of unit testing frameworks
See also
Unit testing in general:
*
Unit testing
*
Software testing
Software testing is the act of examining the artifacts and the behavior of the software under test by validation and verification. Software testing can also provide an objective, independent view of the software to allow the business to apprecia ...
*
Test Anything Protocol
Programming approach to unit testing:
*
Test-driven development
Test-driven development (TDD) is a software development process relying on software requirements being converted to test cases before software is fully developed, and tracking all software development by repeatedly testing the software against a ...
*
Extreme programming
Extreme programming (XP) is a software development methodology intended to improve software quality and responsiveness to changing customer requirements. As a type of agile software development,"Human Centred Technology Workshop 2006 ", 2006, P ...
References
External links
*
*
* {{cite web , url= http://www.martinfowler.com/bliki/Xunit.html , title= xUnit , series= Testing , first= Martin , last= Fowler , authorlink= Martin Fowler (software engineer) , date= Jan 17, 2006
Unit testing frameworks