Keep it simple : write one test for VO / DTO:
- fill VO / DTO with test data
- save him
- (optional: verify that everything was correctly stored at the database level using pure JDBC)
- upload it
- make sure the loaded VO / DTO and the original match
Production code will evolve and tests should also be kept. Conducting the simplest tests, even if they are repeated, is the best approach to IMHO. Over-engineering the tests or the test environment itself, to make the tests generalized (for example, by reading the reflection fields and filling in the VO / DTO automatically) leads to several problems:
- the time taken to record the test is higher
- an error can be introduced in the test itself
- test maintenance is more difficult because it is more complex
- harder to develop, for example. general code may not work for new VO / DTO types that are slightly different from each other and will be introduced later (this is just an example).
- tests cannot be easily used as an example of how productive code works
Test and productive code are very different in nature . In productive code, you try to avoid duplication and maximize reuse. Productive code can be complicated because it is tested. On the other hand, you should try as simple tests as possible, and duplication is fine. If the duplicated part is broken, the test will still fail.
When changing a productive code, this may require several changes three times. The problem is that tests are seen as a boring piece of code. But I think it should be so.
If, however, I misunderstood your question, just let me know.
source share