88 User Acceptance Test
99 Verification that software functions as intended from the user’s
1010 perspective and that users accept the software. Acceptance tests are
11- primarily used in :term: ` Extreme Programming`.
11+ primarily used in :term: `Extreme Programming `.
1212
1313 Argument
1414 A value that is passed to a function. There are two types of arguments:
@@ -630,8 +630,11 @@ Glossary
630630 * :ref: `wheels `
631631
632632 whey
633- Simple Python :term: `wheel ` builder with automation options for
634- :term: `trove-classifiers `.
633+ A simulated version of a class or method. It has a functional
634+ implementation but uses a kind of shortcut, making it unsuitable for
635+ production use. For example, an in-memory database might be used for
636+ testing purposes but not in production. In this context, the in-memory
637+ database would act as a fake.
635638
636639 .. _end-packaging :
637640
@@ -668,7 +671,7 @@ Glossary
668671 :doc: `/test/unittest `
669672 supports you in the automation of tests.
670673 :doc: `/test/mock `
671- allows you to create and use mock objects.
674+ allows you to create and use :term: ` Mock ` objects.
672675 :doc: `../document/doctest `
673676 allows you to test tests written in Python :term: `docstrings
674677 <Docstring> `.
@@ -689,23 +692,41 @@ Glossary
689692 platforms.
690693
691694 Dummy
692- Object that is passed around but never actually used. Normally dummies
693- are only used to fill :term: `parameter ` lists.
695+ An object that is passed along but is not intended for use in your tests.
696+ It has no effect whatsoever on the behaviour of your tests. An example of
697+ a dummy could be an attribute that is required to instantiate a class but
698+ is not needed for the test.
694699
695700 ``except ``
696701 Keyword used to intercept an :term: `exception ` and handle it carefully.
697702
698703 Fake
699- Object that has an implementation that actually works, but usually takes
700- a shortcut that makes it unsuitable for production.
704+ A simulated version of a class or method. It has a functional
705+ implementation but uses a kind of shortcut, making it unsuitable for
706+ production use. For example, an in-memory database might be used for
707+ testing purposes but not in production. In this context, the in-memory
708+ database would act as a fake.
701709
702710 Integration test
703711 Tests that check whether the different parts of the software work
704712 together as expected.
705713
706714 Mock
707- Objects programmed with :term: `exceptions <exception> ` that form a
708- specification of the calls you are likely to receive.
715+ A mock simulates attributes, classes and methods. This enables developers
716+ to
717+
718+
719+ * test certain aspects of their code more effectively
720+ * test in a controlled environment
721+ * test for external dependencies
722+
723+ Unlike :term: `stubs <Stub> `, a mock can be used not only to verify the
724+ result, but also to check **how ** the result was achieved or whether the
725+ correct methods were called.
726+
727+ The Python library for mocks is :doc: `unittest.mock <../test/mock >`. It
728+ is also supported by :doc: `../test/pytest/index `. Alternatively, however,
729+ you can also use `pytest-mock <https://pypi.org/project/pytest-mock/ >`_.
709730
710731 .. seealso ::
711732 * `Mock object <https://en.wikipedia.org/wiki/Mock_object >`_
@@ -720,30 +741,33 @@ Glossary
720741 Tests to protect against new errors or regressions that may occur as a
721742 result of new software and updates.
722743
723- Stubs
724- provide ready-made responses to calls made during the test and usually
725- do not react at all to anything that has not been programmed for the
726- test.
744+ Spy
745+ Spies are used to wrap real objects and, by default, forward all method
746+ calls to the original object. They therefore intercept all calls to a
747+ real object and log them. This makes it possible to monitor calls to the
748+ original object (for example, how often a particular method has been
749+ called) without replacing the original object (as a :term: `mock ` would
750+ do, for instance).
751+
752+ Stub
753+ A non-real object with pre-programmed behaviour. In most cases, stubs
754+ simply return fixed values, known as *canned data *.
727755
728756 Test-driven development
729757 TDD
730- A technique for creating software that guides software development by
758+ A software development technique that guides the development process by
731759 writing tests. It was developed in the late 1990s by Kent Beck as part of
732- Extreme Programming. Essentially, it involves repeating three simple
733- steps:
760+ :term: ` Extreme Programming ` . Essentially, it involves repeating three
761+ simple steps:
734762
735763 * Write a test for the next feature to be added.
736764 * Write the function code until the test passes.
737- * Refactor both the new and old code to make it well structured.
765+ * Revise both the new and the old code to ensure it is well structured.
738766
739- Although these three steps, often summarised as *‘red – green –
740- refactor’ *, form the core of the process, there is also an important
741- first step, in which a list of test cases is created. One of these tests
742- is then selected, *‘Red – Green – Refactor’ * is applied to it, and the
743- next test is selected. During the process, further tests are added to
744- this list.
767+ These three steps are often summarised as *‘Red – Green – Refactor’ *.
745768
746769 .. seealso ::
770+ * :doc: `../test/tdd `
747771 * `Canon TDD <https://tidyfirst.substack.com/p/canon-tdd >`_ by Kent
748772 Beck
749773 * `Test-driven development by example
0 commit comments