origin-energy / java-snapshot-testing

Facebook style snapshot testing for JAVA Tests
MIT License
109 stars 15 forks source link

Is that possible to generate different .snap files according to different tests in one Class #114

Closed zhuoran-guo closed 1 year ago

zhuoran-guo commented 1 year ago

hello, I have a new question. I want to know is that possible to generate different .snap files according to different tests in one Java Class for example my test is like: I have two test in class ChartEdgeAISnapshot , and I want to know is that possible to generate 2 different .snap file like inferenceIncamDetectionVideoSnapshot.snap and inferenceIncamDistractionVideoSnapshot.snap ? thank you so much

public class ChartEdgeAISnapshot {
    ....
    SnapshotVerifier snapshotVerifier = new SnapshotVerifier(
          new PropertyResolvingSnapshotConfig(), ChartEdgeAISnapshot.class);
    ....
    // test1
    public void inferenceIncamDetectionVideoSnapshot() throws Exception {
    ......
    Expect expect = Expect.of(snapshotVerifier,
            ChartEdgeAISnapshot.class.getMethod("inferenceIncamDetectionVideoSnapshot"));
    expect.scenario(version).toMatchSnapshot(resultsIncam);
    snapshotVerifier.validateSnapshots();
    }

    // test2 
    public void inferenceIncamDistractionVideoSnapshot() throws Exception {
    .....
    Expect expect = Expect.of(snapshotVerifier,
            ChartEdgeAISnapshot.class.getMethod("inferenceIncamDistractionVideoSnapshot"));
    expect.scenario(version).toMatchSnapshot(resultsIncam);
    snapshotVerifier.validateSnapshots();
    }
}
jackmatt2 commented 1 year ago

Not currently. The workaround is to have two different test classes

InferenceIncamDetectionVideoSnapshot.java
InferenceIncamDistractionVideoSnapshot.java
zhuoran-guo commented 1 year ago

thank you so much