Content deleted Content added
Edgy4 (talk | contribs)
m Set-up: "set-up" --> "set up" (used as a verb)
Edgy4 (talk | contribs)
Line 13: Line 13:
A software test fixture sets up the system for the testing process by providing it with all the necessary code to initialize it, thereby satisfying whatever preconditions there maybe.<ref name=":0">{{Cite journal|last=Pereira da Silva|first=Lucas|date=June 10, 2016|title=Execution and code reuse between test classes|url=https://www.computer.org/csdl/proceedings/sera/2016/0809/00/07516134-abs.html|journal=SERA 2016|volume=|issue=|doi=|pmid=|access-date=|via=}}</ref> An example could be loading up a database with known parameters from a customer site before running your test. The [[Ruby on Rails]] web framework uses [[YAML]] to initialize a database before running a test.<ref>{{Cite web|url=http://guides.rubyonrails.org/testing.html|title=A Guide to Testing Rails Applications|website=|access-date=}}</ref> This allows for tests to be repeatable, which is one of the key features of an effective test framework.<ref name=":0" />
A software test fixture sets up the system for the testing process by providing it with all the necessary code to initialize it, thereby satisfying whatever preconditions there maybe.<ref name=":0">{{Cite journal|last=Pereira da Silva|first=Lucas|date=June 10, 2016|title=Execution and code reuse between test classes|url=https://www.computer.org/csdl/proceedings/sera/2016/0809/00/07516134-abs.html|journal=SERA 2016|volume=|issue=|doi=|pmid=|access-date=|via=}}</ref> An example could be loading up a database with known parameters from a customer site before running your test. The [[Ruby on Rails]] web framework uses [[YAML]] to initialize a database before running a test.<ref>{{Cite web|url=http://guides.rubyonrails.org/testing.html|title=A Guide to Testing Rails Applications|website=|access-date=}}</ref> This allows for tests to be repeatable, which is one of the key features of an effective test framework.<ref name=":0" />


=== Set up ===
=== Setup ===
Test fixtures can be set up in three ways: in-line setup, delegate setup, and implicit setup. In-line setup is where the developer creates the test fixture in the same method as the rest of the test and is the simplest test fixture to create but can lead to duplication if multiple tests need to same initial data. Delegate setup is where the developer places the test fixture in a separate standalone helper method that can be accessed by multiple test methods. Implicit setup is where the developer places the test fixture in a setup method which is used to setup multiple test methods. This is different from delegate setup in that the overall setup of multiple tests are in a single setup method where the test fixture gets created instead of each test method having its own setup procedures and linking to an external test fixture.<ref name=":1">{{Cite journal|last=Greiler|first=Michaela|year=2013|title=Strategies for Avoiding Text Fixture Smells during Software Evolution|url=http://www.michaelagreiler.com/blog/wp-content/uploads/2013/05/MSR_2013_camera-ready.pdf|journal=MSR 2013|access-date=|via=}}</ref>
Test fixtures can be set up in three ways: in-line setup, delegate setup, and implicit setup. In-line setup is where the developer creates the test fixture in the same method as the rest of the test and is the simplest test fixture to create but can lead to duplication if multiple tests need to same initial data. Delegate setup is where the developer places the test fixture in a separate standalone helper method that can be accessed by multiple test methods. Implicit setup is where the developer places the test fixture in a setup method which is used to setup multiple test methods. This is different from delegate setup in that the overall setup of multiple tests are in a single setup method where the test fixture gets created instead of each test method having its own setup procedures and linking to an external test fixture.<ref name=":1">{{Cite journal|last=Greiler|first=Michaela|year=2013|title=Strategies for Avoiding Text Fixture Smells during Software Evolution|url=http://www.michaelagreiler.com/blog/wp-content/uploads/2013/05/MSR_2013_camera-ready.pdf|journal=MSR 2013|access-date=|via=}}</ref>



Revision as of 16:47, 5 October 2016

A test fixture is something 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 in place and allow it to be tested by being subjected to controlled electronic test signals.

Side connectors, centering pins, test needles, pre-centering parts.
A Functional Test Fixture is a complex device to interface the DUT to the automatic test equipment (ATE)

Examples are a bed of nails tester or SmartFixture.

Software

A software test fixture sets up the system for the testing process by providing it with all the necessary code to initialize it, thereby satisfying whatever preconditions there maybe.[1] An example could be loading up a database with known parameters from a customer site before running your test. The Ruby on Rails web framework uses YAML to initialize a database before running a test.[2] This allows for tests to be repeatable, which is one of the key features of an effective test framework.[1]

Setup

Test fixtures can be set up in three ways: in-line setup, delegate setup, and implicit setup. In-line setup is where the developer creates the test fixture in the same method as the rest of the test and is the simplest test fixture to create but can lead to duplication if multiple tests need to same initial data. Delegate setup is where the developer places the test fixture in a separate standalone helper method that can be accessed by multiple test methods. Implicit setup is where the developer places the test fixture in a setup method which is used to setup multiple test methods. This is different from delegate setup in that the overall setup of multiple tests are in a single setup method where the test fixture gets created instead of each test method having its own setup procedures and linking to an external test fixture.[3]

Advantages and disadvantages

The advantages of test fixture are that it allows for tests to be repeatable since you are always starting with the same setup every time. Test fixtures also eases test code design by allowing the developer to separate methods into different functions and reuse each function for other tests. It also preconfigures tests into a known state at start instead of working with whatever was left from a previous test run. A disadvantage would be that it could lead to duplication of test fixtures if using in-line setup.[1][3]

Practices to avoid

It is considered bad practice when test fixtures are too general in implicit setup, or when the 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 would be a test setup that contains more steps than what is needed for the test, this is a problem seen in in-line setup.[3]

A test case is considered unsafe when it modifies the fixtures during the setup phase. This is more pronounced in the fixture setups other than the in-line setup. An unsafe test case is a serious problem, one that could render subsequent tests useless by leaving the fixture in an unexpected state. Also, the order of tests is important, so that you know whether a fixture setup needs to be rerun or not. If a safe test is run after an unsafe test then the fixture setup is rerun if the fixture is common for both but the same is not true for vice versa.[1]

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 and set-up/creation of mock objects.

Software used to systematically run reproducible tests on a piece of software under test is known as a test harness; part of its job is to set up suitable test fixtures.

In generic xUnit, a test fixture is all the things that must be in place in order to run a test and expect a particular outcome.[4]

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:

  1. Set-up
  2. Exercise, interacting with the system under test
  3. Verify, determining whether the expected outcome has been obtained
  4. Tear down, to return to the original state

Physical testing

In physical testing, a fixture is a device or apparatus to hold or support the test specimen during the test. The influence of test fixtures on test results is important and is an ongoing subject of research.[5]

Many test methods detail the requirements of test fixtures in the text of the document.[6][7]

Some fixtures employ clamps, wedge grips and pincer grips.

Further types of construction are eccentric roller fixtures, thread grips and button head grips as well as rope grips.

Mechanical holding apparatus provide the clamping force via arms, wedges or eccentric wheel to the jaws. Additional there are pneumatic and hydraulic fixtures for tensile testing that do allow very fast clamping procedures and very high clamping forces

See also

References

  1. ^ a b c d Pereira da Silva, Lucas (June 10, 2016). "Execution and code reuse between test classes". SERA 2016.
  2. ^ "A Guide to Testing Rails Applications".
  3. ^ a b c Greiler, Michaela (2013). "Strategies for Avoiding Text Fixture Smells during Software Evolution" (PDF). MSR 2013.
  4. ^ Meszaros, Gerard (2007). "xUnit Test Patters" (PDF).
  5. ^ Abadalah, MG; Gascoigne, HE (1989). The Influence of Test Fixture Design on the Shear Test for Fiber Composite Materials. ASTM STP.
  6. ^ ASTM B829 Test for Determining the Formability of copper Strip
  7. ^ ASTM D6641 Compressive Properties of Polymer Matrix Using a Combined Loading Compression Test Fixture
No tags for this post.