From 3dc4de817337e755c07b5f67c1a3d58a1c2f6cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Thu, 17 Aug 2017 22:29:04 +0200 Subject: [PATCH] Document implementation of listeners in non-main files Closes #991 --- docs/configuration.md | 8 ++++++++ docs/event-listeners.md | 7 ++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 4c236850..59712020 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -9,6 +9,14 @@ Nonetheless there are still some occasions where finer control is needed. For th Although Catch is header only it still, internally, maintains a distinction between interface headers and headers that contain implementation. Only one source file in your test project should compile the implementation headers and this is controlled through the use of one of these macros - one of these identifiers should be defined before including Catch in *exactly one implementation file in your project*. +# Reporter / Listener interfaces + + CATCH_CONFIG_EXTERNAL_INTERFACES // Brings in neccessary headers for Reporter/Listener implementation + +Brings in various parts of Catch that are required for user defined Reporters and Listeners. This means that new Reporters and Listeners can be defined in this file as well as in the main file. + +Implied by both `CATCH_CONFIG_MAIN` and `CATCH_CONFIG_RUNNER`. + # Prefixing Catch macros CATCH_CONFIG_PREFIX_ALL diff --git a/docs/event-listeners.md b/docs/event-listeners.md index ab057444..58c2d8db 100644 --- a/docs/event-listeners.md +++ b/docs/event-listeners.md @@ -12,10 +12,11 @@ so you are not forced to implement events you're not interested in. ## Implementing a Listener +Simply derive a class from `Catch::TestEventListenerBase` and implement the methods you are interested in, either in +the main source file (i.e. the one that defines `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER`), or in a +file that defines `CATCH_CONFIG_EXTERNAL_INTERFACES`. -In your main source file (i.e. the one that has the `#define` for `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER`), -simply derive a class from `Catch::TestEventListenerBase` and implement the methods you are interested in. -Then register it using `INTERNAL_CATCH_REGISTER_LISTENER`. +Then register it using `CATCH_REGISTER_LISTENER`. For example: