Skip to content

Support parameterised tests #21

Open
@dspasojevic

Description

@dspasojevic

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions