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

Specifically setting delimiter #140

Open
seppaleinen opened this issue Oct 18, 2017 · 1 comment
Open

Specifically setting delimiter #140

seppaleinen opened this issue Oct 18, 2017 · 1 comment
Labels

Comments

@seppaleinen
Copy link

I would love to be able to specifically set the delimiter to be used in the @parameters annotation, so that I would be able to input strings with commas in them.

Kind of like with the awk -F'|' command

I'm thinking somewhere along the lines of this example

	@Test
	@Parameters({"hello, goodmorning|goodnight"}, delimiter="|")
	public void test(String str, String str2) {
		System.out.println(str + ":" + str2);
	}

I'm open to there being reasons for this being a bad idea, or that I've missed something :)

@zbychupragmatists
Copy link
Contributor

We will not introduce such change for couple of reasons. The most important is that @Parameters annotation abstraction supports many types of "source" of parameters - you can provide parameters by String, method or csv file (using source + provider). So it's too general to introduce it there.

It's easy to make it work by providing params with method e.g.

    @Test
    @Parameters(method = "paramsByPipe")
    public void byPipe(String parameter) {
        System.out.println("parameter: " + parameter);
    }

    @Test
    @Parameters(method = "paramsByComma")
    public void byComma(String parameter) {
        System.out.println("parameter: " + parameter);
    }

    public List<String> paramsByPipe() {
        return splitBy("hello, goodmorning|goodnight", "\\|");
    }

    public List<String> paramsByComma() {
        return splitBy("hello, goodmorning|goodnight", ",");
    }

    private ArrayList<String> splitBy(String params, String splitter) {
        return Lists.newArrayList(params.split(splitter));
    }

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

No branches or pull requests

2 participants