Pergunta

When I run java tests that use xmlbeans generated objects, sometimes in gradle test when using the setter the object gets into some unknown state. Here is an example (pseudocode):

XmlBeansDoc doc = SomeXmlBeansGeneratedDocument.factory.newInstance();
doc.addSomeObject();
XmlbeansObj obj = doc.getSomeObject();
obj.setSomeIntValue(1);

Right after using the 'setSomeIntValue()' method, if you try and get the value it returns an error. However, if you use the 'setSomeIntValue()' method again, everything works fine and the value is actually set.

This ONLY seems to happen when running the test in Gradle. If I use the exact same jar that Gradle is using, but run the test in ANT, everything works fine. I have confirmed that both ANT and Gradle are using the same version of java (1.7.45).

Any ideas as to why this might be happening? We are in the process of switching our build system from ANT/ivy to Gradle, but if we can't get this working it might be a show stopper. Thanks for all the help

Foi útil?

Solução

It looks like this was ultimately due to gradle having Java Assertions enabled by default, which ant does not.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top