Skip to content

Commit

Permalink
Fix handling of -reporter on cli and <reporter> tag in ant task
Browse files Browse the repository at this point in the history
1. Reverted previous changes to ReporterConfig. Made scope for everything public again. This is needed for the ant task to function properly
2. Removed REPORTER_LIST and related var from CommandlineArgs
3. Replaced it with usage of REPORTER. This is what is being passed in from Ant task and is also part of the cli documentation.

Checked that previously, reporter configs were not being picked up from ant task and after changes they are.

Also, all tests pass.
  • Loading branch information
nullin committed Oct 19, 2010
1 parent 62dc542 commit a477952
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
7 changes: 0 additions & 7 deletions src/main/java/org/testng/CommandLineArgs.java
Expand Up @@ -82,13 +82,6 @@ public class CommandLineArgs {
@Parameter(names = REPORTER, description = "Extended configuration for custom report listener")
public String reporter;

/**
* Used as map key for the complete list of report listeners provided with the above argument
*/
public static final String REPORTERS_LIST = "-reporterslist";
@Parameter(names = REPORTERS_LIST, hidden = true)
public String reportersList;

public static final String USE_DEFAULT_LISTENERS = "-usedefaultlisteners";
@Parameter(names = USE_DEFAULT_LISTENERS, description = "Whether to use the default listeners")
public String useDefaultListeners = "true";
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/org/testng/ReporterConfig.java
Expand Up @@ -11,9 +11,11 @@
* Stores the information regarding the configuration of a pluggable report listener. Used also
* in conjunction with the &lt;reporter&gt; sub-element of the Ant task
*
* NOTE: this class needs to be public. It's used by TestNG Ant task
*
* @author Cosmin Marginean, Apr 12, 2007
*/
class ReporterConfig {
public class ReporterConfig {

/**
* The class name of the reporter listener
Expand All @@ -25,7 +27,7 @@ class ReporterConfig {
*/
private List<Property> m_properties = Lists.newArrayList();

private void addProperty(Property property) {
public void addProperty(Property property) {
m_properties.add(property);
}

Expand All @@ -41,7 +43,7 @@ public void setClassName(String className) {
this.m_className = className;
}

protected String serialize() {
public String serialize() {
StringBuffer sb = new StringBuffer();
sb.append(m_className);
if (!m_properties.isEmpty()) {
Expand All @@ -60,7 +62,7 @@ protected String serialize() {
return sb.toString();
}

protected static ReporterConfig deserialize(String inputString) {
public static ReporterConfig deserialize(String inputString) {
ReporterConfig reporterConfig = null;
if (!Utils.isStringEmpty(inputString)) {
reporterConfig = new ReporterConfig();
Expand Down Expand Up @@ -91,7 +93,7 @@ protected static ReporterConfig deserialize(String inputString) {
/**
* Creates a reporter based on the current configuration
*/
protected Object newReporterInstance() {
public Object newReporterInstance() {
Object result = null;
Class reporterClass = ClassHelper.forName(m_className);
if (reporterClass != null) {
Expand All @@ -103,7 +105,7 @@ protected Object newReporterInstance() {
return result;
}

private static class Property {
public static class Property {
private String name;
private String value;

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/testng/TestNG.java
Expand Up @@ -1229,8 +1229,8 @@ protected void configure(CommandLineArgs cla) {
ClassHelper.fileToClass(cla.testRunnerFactory));
}

if (cla.reportersList != null) {
ReporterConfig reporterConfig = ReporterConfig.deserialize(cla.reportersList);
if (cla.reporter != null) {
ReporterConfig reporterConfig = ReporterConfig.deserialize(cla.reporter);
addReporter(reporterConfig);
}

Expand Down Expand Up @@ -1354,9 +1354,9 @@ public void configure(Map cmdLineArgs) {
result.testRunnerFactory = runnerFactory;
}

String reporterConfigs = (String) cmdLineArgs.get(CommandLineArgs.REPORTERS_LIST);
String reporterConfigs = (String) cmdLineArgs.get(CommandLineArgs.REPORTER);
if (reporterConfigs != null) {
result.reportersList = reporterConfigs;
result.reporter = reporterConfigs;
}

String failurePolicy = (String)cmdLineArgs.get(CommandLineArgs.CONFIG_FAILURE_POLICY);
Expand Down

0 comments on commit a477952

Please sign in to comment.