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

Support parameterised tests #21

Open
dspasojevic opened this issue Apr 9, 2019 · 1 comment
Open

Support parameterised tests #21

dspasojevic opened this issue Apr 9, 2019 · 1 comment

Comments

@dspasojevic
Copy link

Hi,

When using JUnit's Parameterized test runner, snapshot testing can not be used, as only one snapshot per test method is permitted due to the way that the snapshot is resolved on subsequent runs.

I've tried a small change to support passing qualifiers through to the matcher:

private String someParameter;

public ATestClass(String someParameter) throws IOException {
	this.someParameter = someParameter;
}

@Test
public void test() throws Exception {

	Object actual = ...

	expect(actual).toMatchSnapshot(someParameter);
}

and

public void toMatchSnapshot(Object... qualifiers) {

This seems to work pretty well. The .snap ends up as you would expect:

ATestClass.test(theValueOfSomeParameter)=[

I'm happy to raise a PR if this would be of interest.

Thanks,
-Dan

@jackmatt2
Copy link

jackmatt2 commented Jul 3, 2019

I have implemented this as part of #23. You would be able to do expectScenario() for each iteration with a unique identifier per scenario.

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

No branches or pull requests

2 participants