XUnit

Last updated

xUnit is a label used for an automated testing software framework that shares significant structure and functionality that is traceable to a common progenitor SUnit.

Contents

The SUnit framework was ported to Java by Kent Beck and Erich Gamma as JUnit which gained wide popularity. Adaptations to other languages were also popular which led some to claim that the structured, object-oriented style works well with popular languages including Java and C#.

The name of an adaptation is often a variation of "SUnit" with the "S" replaced with an abbreviation of the target language name. For example, JUnit for Java and RUnit for R. The term "xUnit" refers to any such adaptation where "x" is a placeholder for the language-specific prefix.

The xUnit frameworks are often used for unit testing testing an isolated unit of code but can be used for any level of software testing including integration and system.

Architecture

An xUnit framework has the following general architecture. [1]

Test case

A test case is the smallest part of a test that generally encodes a simple path through the software under test. The test case code prepares input data and environmental state, invokes the software under test and verifies expected results.

A programmer writes the code for each test case.

Assertions

A test case is implemented with one or more assertions that validate expected results.

Generally, the framework provides assertion functionality. A framework may provide a way to use custom assertions.

Test suite

A test suite is a collection of related test cases. They share a framework which allows for reuse of environment setup and cleanup code.

Generally, a test runner may run the cases of a suite in any order so the programmer should not depend on top-to-bottom execution order.

Test fixture

A test fixture (also known as a test context) provides the environment for each test case of a suite. Generally, a fixture is configured to setup a known, good, runtime environment before tests run, and to cleanup the environment after.

The fixture is configured with one or more functions that setup and cleanup state. The test runner runs each setup function before each case and runs each cleanup function after.

Test runner

A test runner is a program that runs tests and reports results. [2] The program is often part of a framework.

A test runner may produce results in various formats. Often, a common and default format is human-readable, plain-text. Additionally, the runner may produce structured output. Some xUnit adaptations (i.e. JUnit) can output XML that can be used by a continuous integration system such as Jenkins and Atlassian Bamboo.

See also

Related Research Articles

JUnit is a test automation framework for the Java programming language. JUnit is often used for unit testing, and is one of the xUnit frameworks.

<span class="mw-page-title-main">Kent Beck</span> American software engineer

Kent Beck is an American software engineer and the creator of extreme programming, a software development methodology that eschews rigid formal specification for a collaborative and iterative design process. Beck was one of the 17 original signatories of the Agile Manifesto, the founding document for agile software development. Extreme and Agile methods are closely associated with Test-Driven Development (TDD), of which Beck is perhaps the leading proponent.

In computing, cross-platform software is computer software that is designed to work in several computing platforms. Some cross-platform software requires a separate build for each platform, but some can be directly run on any platform without special preparation, being written in an interpreted language or compiled to portable bytecode for which the interpreters or run-time packages are common or standard components of all supported platforms.

Unit testing, a.k.a. component or module testing, is a form of software testing by which isolated source code is tested to validate expected behavior.

Test-driven development (TDD) is a way of writing code that involves writing an automated unit-level test case that fails, then writing just enough code to make the test pass, then refactoring both the test code and the production code, then repeating with another new test case.

<span class="mw-page-title-main">NUnit</span>

NUnit is an open-source unit testing framework for the .NET Framework and Mono. It serves the same purpose as JUnit does in the Java world, and is one of many programs in the xUnit family.

In software testing, test automation is the use of software separate from the software being tested to control the execution of tests and the comparison of actual outcomes with predicted outcomes. Test automation can automate some repetitive but necessary tasks in a formalized testing process already in place, or perform additional testing that would be difficult to do manually. Test automation is critical for continuous delivery and continuous testing.

Maven is a build automation tool used primarily for Java projects. Maven can also be used to build and manage projects written in C#, Ruby, Scala, and other languages. The Maven project is hosted by The Apache Software Foundation, where it was formerly part of the Jakarta Project.

SUnit is an automated testing framework written by Kent Beck in 1998; originally intended and often used for unit testing. It supports testing Smalltalk code via test code also written in Smalltalk.

TestNG is a testing framework for the Java programming language created by Cedric_Beust and inspired by JUnit and NUnit. The design goal of TestNG is to cover a wider range of test categories: unit, functional, end-to-end, integration, etc., with more powerful and easy-to-use functionalities.

In software testing, a test harness is a collection of stubs and drivers configured to assist with the testing of an application or component. It acts as imitation infrastructure for test environments or containers where the full infrastructure is either not available or not desired.

Seasar2 is an open-source application framework similar to the Spring Framework (Java). Initially, it was developed for the Java platform by Yasuo Higa, but .NET and PHP platforms are currently supported as well. Seasar2 has a large base of Japanese users, but there is a steady increase of non-Japanese users since English support was announced at the JavaOne 2005 Tokyo conference.

A test fixture is a device used to consistently test some item, device, or piece of software. Test fixtures are used in the testing of electronics, software and physical devices.

<span class="mw-page-title-main">PHPUnit</span> Testing software

PHPUnit is a unit testing framework for the PHP programming language. It is an instance of the xUnit architecture for unit testing frameworks that originated with SUnit and became popular with JUnit. PHPUnit was created by Sebastian Bergmann and its development is hosted on GitHub.

Hamcrest is a framework that assists writing software tests in the Java programming language. It supports creating customized assertion matchers, allowing match rules to be defined declaratively. These matchers have uses in unit testing frameworks such as JUnit and jMock. Hamcrest has been included in JUnit 4 since 2012, but was omitted from JUnit 5 in 2017.

Concordion is a specification by example framework originally developed by David Peterson, and now maintained by a team of contributors, led by Nigel Charman.

xUnit.net Software testing framework for .NET software framework

xUnit.net is a free and open-source unit testing tool for the .NET Framework, written by the original author of NUnit. The software can also be used with .NET Core and Mono.

MockServer is an open source mocking framework for HTTP and HTTPS released under the Apache License. MockServer is designed to simplify integration testing, by mocking HTTP and HTTPS system such as a web service or web site, and to decouple development teams, by allowing a team to develop against a service that is not complete or is unstable.

pytest Software testing framework

Pytest is a Python testing framework that originated from the PyPy project. It can be used to write various types of software tests, including unit tests, integration tests, end-to-end tests, and functional tests. Its features include parametrized testing, fixtures, and assert re-writing.

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