请输入您要查询的百科知识:

 

词条 Test fixture
释义

  1. Electronics

  2. Software

      Setup    Advantages and disadvantages    Practices to avoid    Examples  

  3. Physical testing

  4. See also

  5. References

  6. External links

{{about|testing fixtures|other uses|Fixture (disambiguation)}}

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.

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 may be.[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 three different ways: in-line, delegate, and implicit.

  1. 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.
  2. Delegate setup places the test fixture in a separate standalone helper method that is accessed by multiple test methods.
  3. 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.&91;3&93;

Advantages and disadvantages

The advantage of a test fixture is that it allows for tests to be repeatable since one is always starting with the same setup every time. Test fixtures also ease 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 is 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 are 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 which could render subsequent tests useless by leaving the fixture in an unexpected state. It also causes the order of tests to be 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 which is used to run reproducible tests systematically 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 include eccentric roller fixtures, thread grips and button head grips and rope grips.

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.

See also

  • Unit testing

References

1. ^{{Cite book|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=|pages=99–106|doi=10.1109/SERA.2016.7516134|pmid=|access-date=|via=|isbn=978-1-5090-0809-4}}
2. ^{{Cite web|url=http://guides.rubyonrails.org/testing.html|title=A Guide to Testing Rails Applications|website=|access-date=}}
3. ^{{cite conference|last1=Greiler|first1=Michaela|last2=Zaidman|first2=Andy|last3=van Deursen|first3=Arie|last4=Storey|first4=Margaret-Anne|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|conference=10th IEEE Working Conference on Mining Software Repositories (MSR)|access-date=24 January 2014|doi=10.1109/MSR.2013.6624053}}
4. ^{{Cite book |url=http://buhoz.net/public/books/computacion/desarrollo/metodologias/agiles/xUnit.Test.Patterns.Refactoring.Test.Code.2007.pdf|title=xUnit Test Patterns: Refactoring Test Code|last=Meszaros|first=Gerard|year=2007|isbn=978-0-13-149505-0|archive-url=https://web.archive.org/web/20160923114822/http://buhoz.net/public/books/computacion/desarrollo/metodologias/agiles/xUnit.Test.Patterns.Refactoring.Test.Code.2007.pdf|archive-date=23 September 2016|publisher=Addison-Wesley Professional}}
5. ^{{Cite book | last = Abadalah | first = MG |author2=Gascoigne, HE | title = The Influence of Test Fixture Design on the Shear Test for Fiber Composite Materials | publisher = ASTM STP | year = 1989 }}
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

External links

{{External links|date=May 2017}}
  • [https://web.archive.org/web/20110709004120/http://www.cs.utep.edu/cheon/cs3331/notes/unit-testing.ppt Unit Testing with JUnit], by Yoonsik Cheon
  • The Low-Down on fixtures, from A Guide to Testing Rails Applications

2 : Unit testing|Tests

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/12 12:39:12