質問

My team and i have a large web application we're porting to use the Symfony framework which includes Doctrine2 for data access. As we're just starting, we're wondering about regression testing for the entity relationships later on.

We have a large number of Doctrine entities that we have automagically generated from the database schema and are now in the process of checking and tidying up each one specifically in the area of relationship mapping. Once the mapping is done (using doc block annotations) and we confirm via simple scripts that the entities are performing correct data access, what is the best way to ensure the mapping and therefore the functionality of the entities don't break in future.

We are writing unit tests for all the entities as standalone units, mocking the required dependencies but this doesn't necessarily protect us from an annotation comment being edited or the schema changing and breaking the current entity relationships.

Any thoughts? Anybody here had the same issues?

役に立ちましたか?

解決

We have created what we term functional tests for every top level entity to test the relationships of child entities to that one. Basically a top level entity is instantiated and mock data is used to populate it then all its entity dependencies are added themselves being populated with mock data. This is all then persisted to the database in one operation. The entity is then read back from the database and the tested for equality against the original data. It's a bit more complicated than that (especially the equality test) but if any of the relationship mappings are ever changed or bugged this test immediately fails and give us a que to investigate.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top