test_organization.qbk 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. [/
  2. / Copyright (c) 2003 Boost.Test contributors
  3. /
  4. / Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. /]
  7. [section:tests_organization Declaring and organizing tests]
  8. If you look at many legacy test modules, big chance is that it's implemented as one big test function that
  9. consists of a mixture of check and output statements. Is there anything wrong with it? Yes. There are various
  10. disadvantages in single test function approach:
  11. * One big function tends to become really difficult to manage if the number of checks exceeds a reasonable limit
  12. (true for any large function). What is tested and where - who knows?
  13. * Many checks require similar preparations. This results in code repetitions within the test function.
  14. * If a fatal error or an exception is caused by any checks within the test function the rest of tests are
  15. skipped and there is no way to prevent this.
  16. * No way to perform only checks for a particular subsystem of the tested unit.
  17. * No summary of how different subsystems of the tested unit performed under in the test.
  18. The above points should make it clear that it's preferable to split a [link ref_test_module test module] into smaller *units*.
  19. These units are the *test cases*, the *test suites* and the *fixtures*.
  20. [variablelist Subjects covered by this section
  21. [
  22. [Declaration]
  23. [The __UTF__ supports several methods for declaring a [link boost_test.tests_organization.test_cases test case].
  24. Test cases can be implemented using free function like syntax or based on actual free function, function object,
  25. that can be defined with or without parameters/data, or as template functions to be run against various types. ]
  26. ]
  27. [
  28. [Organization]
  29. [The __UTF__ provides facilities to group several test cases into [link boost_test.tests_organization.test_tree.test_suite test suites].
  30. The test suites can be nested, and the set of test suites and test cases defines the [link boost_test.tests_organization.test_tree test tree],
  31. where the leaves are the test cases.
  32. Besides hierarchical structure the __UTF__ allows you to organize the test tree using [link boost_test.tests_organization.tests_grouping logical grouping]
  33. and [link boost_test.tests_organization.tests_dependencies dependencies]
  34. and provides you with controls to utilize the defined test tree organization the way you want (eg. from command line).
  35. ]
  36. ]
  37. [
  38. [Attributes]
  39. [It is possible to specify test unit /attributes/ by using [link boost_test.tests_organization.decorators decorators].
  40. Attributes are used for a fine grained control over various aspects of test module execution, such as /logical grouping/,
  41. /dependencies/, /expected failures/, etc.]
  42. ]
  43. [
  44. [Setup/teardown test unit actions]
  45. [When several tests shares the same set-up (environment, test data preparation, etc.), the preparation and cleanup code
  46. may be factorized in [link boost_test.tests_organization.fixtures fixtures].
  47. In the __UTF__, fixtures can be associated to test cases, test suites or globally to the test module.
  48. ]
  49. ]
  50. ]
  51. [include test_cases.qbk]
  52. [include test_tree.qbk]
  53. [include decorators.qbk]
  54. [include fixtures.qbk]
  55. [include managing_tests_dependencies.qbk]
  56. [include logical_grouping.qbk]
  57. [include test_enabling_disabling.qbk]
  58. [include semantic.qbk]
  59. [include testorg_summary.qbk]
  60. [endsect] [/ test organization]
  61. [/EOF]