Skip to content

Multi scenario screenshot test#2590

Merged
yaRnMcDonuts merged 1 commit intojMonkeyEngine:masterfrom
richardTingle:multi-scenario-screenshot-test
Feb 17, 2026
Merged

Multi scenario screenshot test#2590
yaRnMcDonuts merged 1 commit intojMonkeyEngine:masterfrom
richardTingle:multi-scenario-screenshot-test

Conversation

@richardTingle
Copy link
Copy Markdown
Member

As discussed at https://hub.jmonkeyengine.org/t/screenshottests-use-a-image-from-a-different-test-as-reference/49395/4 adds a mechanism to test multiple (theoretically identical) scenarios against a single set of reference images. Example usage:

public class MultiTest extends ScreenshotTestBase {

    @Test
    public void multiTest() {
        
        screenshotMultiScenarioTest(
                new Scenario(
                        "setByParts",
                        new BaseAppState() {
                            @Override
                            protected void initialize(Application app) {
                                Box box = new Box(1, 1, 1);
                                Geometry geom = new Geometry("Box", box);
                                Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
                                mat.setColor("Color", ColorRGBA.Blue);
                                geom.setMaterial(mat);

                                geom.setLocalTranslation(1, 0, 0);

                                ((SimpleApplication) app).getRootNode().attachChild(geom);
                            }

                            @Override
                            protected void cleanup(Application app) {}

                            @Override
                            protected void onEnable() {}

                            @Override
                            protected void onDisable() {}
                        }),
                new Scenario(
                        "setByVector",
                        new BaseAppState() {
                            @Override
                            protected void initialize(Application app) {
                                Box box = new Box(1, 1, 1);
                                Geometry geom = new Geometry("Box", box);
                                Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
                                mat.setColor("Color", ColorRGBA.Blue);
                                geom.setMaterial(mat);

                                geom.setLocalTranslation(new Vector3f(1f, 0, 0));

                                ((SimpleApplication) app).getRootNode().attachChild(geom);
                            }

                            @Override
                            protected void cleanup(Application app) {}

                            @Override
                            protected void onEnable() {}

                            @Override
                            protected void onDisable() {}
                        })
        ).run();
    }
}

It will test that:

  • Every scenario generates the same screenshot(s)
  • The first scenario has the same screenshot(s) as the reference image(s)

@richardTingle richardTingle force-pushed the multi-scenario-screenshot-test branch from dc53005 to e1f0a78 Compare January 28, 2026 16:28
@yaRnMcDonuts yaRnMcDonuts added this to the v3.10.0 milestone Jan 29, 2026
@yaRnMcDonuts yaRnMcDonuts merged commit f09a788 into jMonkeyEngine:master Feb 17, 2026
17 checks passed
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

Successfully merging this pull request may close these issues.

2 participants