Skip to content

jsplot's TemplateUtilsTest is order sensitive, due to static field initialisation problem #761

Closed
@hallvard

Description

TemplateUtilsTest has two test methods, testDefaultTemplateLocation tests that the default template lookup works, testCustomTemplateLocation tests that setting a custom location works. If they run in this order, the second fails, as is does on my mac after a fresh clone and running mvn test. However, it works when run alone (or in a fresh VM).

The problem has to do with initialisation of static fields, templateLocations in TemplateUtils and engine in Component. The engine field captures the value of templateLocation, so later changes doesn't affect it. And since that static engine field is used by Page (while some other Components have non-static engine field), you must set the custom template location before using any Component. This clearly isn't realistic...

I would create a PR, but here I'm not sure what solution is preferred. Personally, I would avoid the static engine field in Component.

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