Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for registering custom listeners #7

Merged
merged 1 commit into from
Jul 9, 2021

Conversation

marcphilipp
Copy link
Member

The new testng.listeners configuration parameter now allows to
register custom listeners as a comma-separated list of fully-qualified
class names.

Fixes #5.

@marcphilipp marcphilipp self-assigned this Jul 9, 2021
The new `testng.listeners` configuration parameter now allows to
register custom listeners as a comma-separated list of fully-qualified
class names.

Fixes #5.
@marcphilipp marcphilipp force-pushed the marc/5-custom-listeners branch from 18d9ad1 to fb1a111 Compare July 9, 2021 15:14
@marcphilipp marcphilipp merged commit 23603e6 into main Jul 9, 2021
@marcphilipp marcphilipp deleted the marc/5-custom-listeners branch July 9, 2021 15:21
@@ -127,6 +127,9 @@ the output directory for reports (default: "test-output")
`testng.useDefaultListeners` (boolean)::
whether TestNG's default report generating listeners should be used (default: `false`)
+
`testng.listeners` (comma-separated list of fully-qualified class names)::
custom listeners that should be registered when executing tests (default: none)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
custom listeners that should be registered when executing tests (default: none)
custom listeners that should be registered when executing tests (default: "")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #9.

@@ -127,6 +127,9 @@ the output directory for reports (default: "test-output")
`testng.useDefaultListeners` (boolean)::
whether TestNG's default report generating listeners should be used (default: `false`)
+
`testng.listeners` (comma-separated list of fully-qualified class names)::
custom listeners that should be registered when executing tests (default: none)
+
`testng.verbose` (integer)::
TestNG's level of verbosity (default: 0)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TestNG's level of verbosity (default: 0)
TestNG's level of verbosity (default: `0`)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #9.

@@ -208,6 +213,18 @@ void configure(TestNG testNG, ConfigurationParameters config) {
testNG.setVerbose(config.get("testng.verbose", Integer::valueOf).orElse(0));
testNG.setUseDefaultListeners(config.getBoolean("testng.useDefaultListeners").orElse(false));
config.get("testng.outputDirectory").ifPresent(testNG::setOutputDirectory);
config.get("testng.listeners").ifPresent(listeners -> Arrays.stream(listeners.split(",")) //
.map(ReflectionSupport::tryToLoadClass) //
Copy link

@l0rinc l0rinc Jul 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #9, I've delegating the parsing of the parameter to TestNG so I don't think we have to test these cases anymore as it now behaves consistently with how TestNG handles -listener on the command line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for registering custom listeners
3 participants