World Library  
Flag as Inappropriate
Email this Article

XUnit

Article Id: WHEBN0000224031
Reproduction Date:

Title: XUnit  
Author: World Heritage Encyclopedia
Language: English
Subject: Unit testing, Kent Beck, Software testing, HtmlUnit, Test-driven development
Collection: Unit Testing Frameworks
Publisher: World Heritage Encyclopedia
Publication
Date:
 

XUnit

For the particular .NET testing framework, see xUnit.net.
For the unit of measurement, see x unit.

xUnit is the collective name for several unit testing frameworks that derive their structure and functionality from Smalltalk's SUnit. SUnit, designed by Kent Beck in 1998, was written in a highly structured object-oriented style, which lent easily to contemporary languages such as Java and C#. Following its introduction in Smalltalk the framework was ported to Java by 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 substituting the "S" for the first letter (or letters) in the name of their intended language ("JUnit" for Java, "RUnit" for R etc.). These frameworks and their common architecture are collectively known as "xUnit".

Contents

  • xUnit architecture 1
    • Test runner 1.1
    • Test case 1.2
    • Test fixtures 1.3
    • Test suites 1.4
    • Test execution 1.5
    • Test result formatter 1.6
    • Assertions 1.7
  • xUnit frameworks 2
  • See also 3
  • References 4
  • External links 5

xUnit architecture

All xUnit frameworks share the following basic component architecture, with some varied implementation details.[1]

Test runner

A test runner is an executable program that runs tests implemented using an xUnit framework and reports the test results.[2]

Test case

A test case 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 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 output. The XML test result format originated with JUnit but is also used by some other xUnit testing frameworks, for instance build tools such as Jenkins 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.

See also

Unit testing in general:

Programming approach to unit testing:

References

  1. ^ Beck, Kent. "Simple Smalltalk Testing: With Patterns". Archived from the original on 15 March 2015. Retrieved 25 June 2015. 
  2. ^ Meszaros, Gerard (2007) xUnit Test Patterns, Pearson Education, Inc./Addison Wesley

External links

  • Other list of various unit testing frameworks
  • OpenSourceTesting.org lists many unit testing frameworks, performance testing tools and other tools programmers/developers may find useful
  • Test automation patterns for writing tests/specs in xUnit.
  • Martin Fowler on the background of xUnit.
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
 
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
 
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.
 


Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.