Test fixture
   HOME

TheInfoList



OR:

A test fixture is an environment used to consistently test some item, device, or piece of software. Test fixtures can be found when testing electronics, software and physical devices.


Electronics

In testing electronic equipment such as circuit boards, electronic components, and chips, a test fixture is a device or setup designed to hold the
device under test A device under test (DUT), also known as equipment under test (EUT) and unit under test (UUT), is a manufactured product undergoing testing, either at first manufacture or later during its life cycle as part of ongoing functional testing and calibra ...
in place and allow it to be tested by being subjected to controlled electronic test signals. Examples are a
bed of nails tester A bed of nails tester is a traditional electronic test fixture used for in-circuit testing. It has numerous pins inserted into holes in an epoxy phenolic glass cloth laminated sheet (G-10) which are aligned using tooling pins to make contact wi ...
or SmartFixture. Electronics Test Fixture.jpg, Side connectors, centering pins, test needles, pre-centering parts. Functional Test Fixture for electroncis.jpg, A functional test fixture is a complex device to interface the
device under test A device under test (DUT), also known as equipment under test (EUT) and unit under test (UUT), is a manufactured product undergoing testing, either at first manufacture or later during its life cycle as part of ongoing functional testing and calibra ...
(DUT) to the automatic test equipment (ATE).


Software

A software test fixture sets up a system for the
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 ...
process by initializing it, thereby satisfying any
precondition In computer programming, a precondition is a condition or predicate that must always be true just prior to the execution of some section of code or before an operation in a formal specification. If a precondition is violated, the effect of the s ...
s the system may have. For example, the
Ruby on Rails Ruby on Rails (simplified as Rails) is a server-side web application framework written in Ruby under the MIT License. Rails is a model–view–controller (MVC) framework, providing default structures for a database, a web service, and we ...
web framework uses
YAML YAML ( and ) (''see '') is a human-readable data-serialization language. It is commonly used for configuration files and in applications where data is being stored or transmitted. YAML targets many of the same communications applications as Exte ...
to initialize a database with known parameters before running a test. This allows for tests to be repeatable, which is one of the key features of an effective test framework.


Setup

Test fixtures can be set up three different ways: in-line, delegate, and implicit. # In-line setup creates the test fixture in the same method as the rest of the test. While in-line setup is the simplest test fixture to create, it leads to duplication when multiple tests require the same initial data. # Delegate setup places the test fixture in a separate standalone helper method that is accessed by multiple test methods. # Implicit setup places the test fixture in a setup method which is used to set up multiple test methods. This differs from delegate setup in that the overall setup of multiple tests is in a single setup method where the test fixture gets created rather than each test method having its own setup procedures and linking to an external test fixture.


Advantages and disadvantages

The main advantage of a test fixture is that it allows for tests to be repeatable since each test is always starting with the same setup. Test fixtures also ease test code design by allowing the developer to separate methods into different functions and reuse each function for other tests. Further, test fixtures preconfigure tests into a known initial state instead of working with whatever was left from a previous test run. A disadvantage is that it could lead to duplication of test fixtures if using in-line setup.


Practices to avoid

It is considered bad practice when implicit test fixtures are too general, or when a test method sets up a test fixture and does not use it during the test. A more subtle issue is if the test methods ignore certain fields within the test fixture. Another bad practice is a test setup that contains more steps than needed for the test; this is a problem seen in in-line setup. 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 considered "unsafe" when it modifies its fixture(s). An unsafe test case can render subsequent tests useless by leaving the fixture in an unexpected state. It also causes the order of tests to be important: a modified fixture must be reset if more tests are to be run after an unsafe test.


Examples

Examples of fixtures include loading a database with a specific known set of data, erasing a hard disk and installing a known clean operating system installation, copying a specific known set of files, or the preparation of input data as well as set-up and creation of
mock object In object-oriented programming, mock objects are simulated objects that mimic the behaviour of real objects in controlled ways, most often as part of a software testing initiative. A programmer typically creates a mock object to test the behaviou ...
s. Software which is used to run reproducible tests systematically on a piece of software under test is known as a
test harness In software testing, a test harness or automated test framework is a collection of software and test data configured to test a program unit by running it under varying conditions and monitoring its behavior and outputs. It has two main parts: the t ...
; part of its job is to set up suitable test fixtures. In generic
xUnit 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 ...
, a ''test fixture'' is all the things that must be in place in order to run a test and expect a particular outcome. Frequently fixtures are created by handling ''setUp()'' and ''tearDown()'' events of the unit testing framework. In ''setUp()'' one would create the expected state for the test and in ''tearDown()'' it would clean up what had been set up. Four phases of a test: # Set-up # Exercise, interacting with the system under test # Verify, determining whether the expected outcome has been obtained # Tear down, to return to the original state


Physical testing

In
physical test A physical test is a qualitative or quantitative procedure that consists of determination of one or more characteristics of a given product, process or service according to a specified procedure. ASTM E 1301, Standard Guide for Proficiency Testing ...
ing, a fixture is a device or apparatus to hold or support the test
specimen Specimen may refer to: Science and technology * Sample (material), a limited quantity of something which is intended to be similar to and represent a larger amount * Biological specimen or biospecimen, an organic specimen held by a biorepository ...
during the test. The influence of test fixtures on test results is important and is an ongoing subject of research. Many
test method A test method is a method for a test in science or engineering, such as a physical test, chemical test, or statistical test. It is a definitive procedure that produces a test result. In order to ensure accurate and relevant test results, a test met ...
s detail the requirements of test fixtures in the text of the document.ASTM D6641 Compressive Properties of Polymer Matrix Using a Combined Loading Compression Test Fixture File:Three point flexural test.jpg, Test fixture on
universal testing machine A universal testing machine (UTM), also known as a universal tester, materials testing machine or materials test frame, is used to test the tensile strength and compressive strength of materials. An earlier name for a tensile testing machine is ...
for three-point flex test File:US Navy 070409-N-3038W-002 Aviation Structural Mechanic 3rd Class Rene Tovar adjusts a connection point on a fixture hydraulic supply servo cylinder test station in the hydraulics shop aboard the Nimitz-class aircraft carrier U.jpg, Hydraulic system testing on fixture File:US Navy 070804-N-1745W-122 A Sailor assigned to Aircraft Intermediate Maintenance Department (AIMD) tests an aircraft jet engine for defects while performing Jet Engine Test Instrumentation, (JETI) Certification-Engine Runs.jpg, jet engine fixtures for operational testing
Some fixtures employ clamps, wedge grips and pincer grips. File:TH11-50kN-pincer-grip.jpg, pincer clamps max. 50 kN spring-biased File:THS527-50.jpg, offset compensated wedge grip max.50 kN File:TH-screw-grips.jpg, different vice and screw grips of a German manufacturer Further types of construction include eccentric roller fixtures, thread grips and button head grips and rope grips. File:THS766-5.jpg, symmetric roller grip, self-closing and self-adjusting File:THS314-2.jpg, multiple button head grip for speedy tests on series File:THS13k-02-200N.jpg, small rope grip 200N to test fine wires File:Temperaturkammer-spannzeug THS321-250-5.jpg, very compact wedge grip for temperature chambers providing extreme temperatures Mechanical holding apparatuses provide the clamping force via arms, wedges or eccentric wheel to the jaws. Additionally there are pneumatic and hydraulic fixtures for tensile testing that allow very fast clamping procedures and very high clamping forces. File:TH149.jpg, pneumatic grip, symmetrical, clamping force 2.4 kN File:THS137-4-fr.jpg, heavy duty hydraulic clamps, clamping force 700 kN File:Biegevorrichtung TH165.jpg, Bending device for tensile testing machines File:Abzugsvorrichtung_TH50+SW.jpg, Equipment to test peeling forces up to 10 kN


See also

*
Unit testing In computer programming, unit testing is a software testing method by which individual units of source code—sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures&md ...


References

{{reflist, colwidth=30em Unit testing Tests