-
Notifications
You must be signed in to change notification settings - Fork 7
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
Conversation
The new `testng.listeners` configuration parameter now allows to register custom listeners as a comma-separated list of fully-qualified class names. Fixes #5.
18d9ad1
to
fb1a111
Compare
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
custom listeners that should be registered when executing tests (default: none) | |
custom listeners that should be registered when executing tests (default: "") |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TestNG's level of verbosity (default: 0) | |
TestNG's level of verbosity (default: `0`) |
There was a problem hiding this comment.
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) // |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- should we trim each value (see https://github.com/junit-team/testng-engine/pull/7/files#r667045387)
- should we deduplicate or throw on duplicated?
- can we test double comma
a,,b
? - can we test leading/trailing comma
a,
or,b
?
There was a problem hiding this comment.
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.
The new
testng.listeners
configuration parameter now allows toregister custom listeners as a comma-separated list of fully-qualified
class names.
Fixes #5.