Skip to content

Plugin formatter having no arg and File arg constructor #1104

New issue

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

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

Already on GitHub? # to your account

Closed
email2vimalraj opened this issue Mar 11, 2017 · 3 comments
Closed

Plugin formatter having no arg and File arg constructor #1104

email2vimalraj opened this issue Mar 11, 2017 · 3 comments
Assignees
Labels
good first issue Good for newcomers ⚡ enhancement Request for new functionality

Comments

@email2vimalraj
Copy link

Summary

If a plugin formatter contains a no-arg constructor and a constructor with one of the valid argument: Appendable, URI, URL or File, always the no-arg constructor is being triggered, even when the valid argument is passed.

Expected Behavior

The no-arg constructor should be a least check where-in if any of the conditions of arg not met, it should fallback to trigger the no-arg constructor if defined.

Current Behavior

Always the no-arg constructor is being triggered.

Possible Solution

The PluginFactory should be updated to consider null as a least priority.

Steps to Reproduce (for bugs)

My own formatter look like this:

public class TestFormatter implements Formatter  {

    public TestListener() {
        System.err.println("Null constructor");
    }

    public TestListener(File file) {
        System.err.println("File Constructor");
    }
}

The runner look like as follows:

@RunWith(Cucumber.class)
@CucumberOptions(
    features = {"src/test/resources/features/MyFeature.feature"},
    glue = {"com.cucumber.stepdefinitions"},
        plugin = {"com.cucumber.listener.TestListener:output/report.html"}
)
public class RunCukesTest {
}

Context & Motivation

The expectation was that the constructor with File argument is called. But, the no-arg constructor is called. The motivation is to when the argument is given, report will be generated at the given location. If not, the no-arg constructor will generate the output at the default location defined by the framework.

Your Environment

@mlvandijk
Copy link
Member

@email2vimalraj Would you like to process the review comments? Otherwise I might give this issue a go...

@email2vimalraj
Copy link
Author

email2vimalraj commented Aug 23, 2017 via email

@lock
Copy link

lock bot commented Oct 24, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 24, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
good first issue Good for newcomers ⚡ enhancement Request for new functionality
Projects
None yet
3 participants