[SOLVED] How to validate Nifty XML on my tests

From Nifty GUI - Best Practices

<h2>Validate the XML before loading</h2>

The Nifty class has validateXml() method that takes the same input XML argument as fromXml(). Nifty does not validate the Xml by default, and will blow up in surprising ways if your XML does not conform to the schema. Adding the validation step will save you debugging time. You can validate right before loading, or in your unit tests.

(Emphasis mine).

Well, I would like to validate on my test. Problem is that I need to create a Nifty object to validate the XML, and I need to start a SimpleApplication to create the Nifty object, so the test is interactive and not automatic.

My conclusion: Iā€™m doing all wrong. Which is the good way to validate XML on my tests?

I validate my XML only when my game loads it.

If you want an app to do nothing but validation, I suggest you make it a headless app using app.start(JmeContext.Type.Headless);

That do the trick. Many thanks.

How do I mark the question as solved?

1 Like