Appfuse – Test failure

Sometimes the tests will fail because you have generated your classes in an order that does not support the tests.
For example, I have a Base class that is included as an attribute of another class. However, I had made a change in the base class and regenerated the code. This causes the file in ./tree/src/test/resources/sample-data.xml to generate the data in the wrong order. So what happens is that there are zero base class records in the table when the other class runs its test. This second class is, due to me regenerating the base class, now first in the sample data and first to be tested.

The fix:
To fix this, just move the data around in the sample-data.xml file. Poof no more Constraint problem.

Example pseduocode:
Class Communications {
Long uid;
Email email;
{ . . . methods . . . }
}
This Communications class is first in the sample-data.xml file because the Email class was generated second
Class Email {
Long uid;
String emailAddr;
{ . . . methods . . .}
}
So initially I had autogenerated the Email class first. Then made an addition to the email class’s attributes. Then regenerated it with
mvn appfuse:gen -Dentity=Email ; mvn appfuse:install -Dentity=Email
Did my fixup of the ./tree/src/main/webapp/WEB-INF/applicationContext.xml
Finally mvn test
So before the mvn test fix the sample-data.xml file and you’ll be fine.

Share
This entry was posted in Miscellaneous Apps and Services and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>