XUnit

Last updated

xUnit is a label used for an automated testing software framework that shares significant structure and functionality with SUnit; designed by Kent Beck in 1998.

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. Collectively, the term "xUnit" is used to refer 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 case 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.

Implementations

See list of unit testing frameworks

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 computer programming, 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) a way of writing code that involves writing an automated 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.

Erich Gamma is a Swiss computer scientist and one of the four co-authors of the software engineering textbook, Design Patterns: Elements of Reusable Object-Oriented Software.

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; 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.

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.

<span class="mw-page-title-main">Play Framework</span> Open-source web framework written in Scala

Play Framework is an open-source web application framework which follows the model–view–controller (MVC) architectural pattern. It is written in Scala and usable from other programming languages that are compiled to JVM bytecode, e.g. Java. It aims to optimize developer productivity by using convention over configuration, hot code reloading and display of errors in the browser.

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.

Acceptance test–driven development (ATDD) is a development methodology based on communication between the business customers, the developers, and the testers. ATDD encompasses many of the same practices as specification by example (SBE), behavior-driven development (BDD), example-driven development (EDD), and support-driven development also called story test–driven development (SDD). All these processes aid developers and testers in understanding the customer's needs prior to implementation and allow customers to be able to converse in their own domain language.

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