reset password
Author Message
aligh1979
Posts: 121
Posted 01:58 Oct 28, 2011 |

There hes been a question / confusion regarding the automatic test in my mind . in hour home work what we do is to assign a "generated"  annotation to  ID fields in order to generate them automatically , and this automatic generation happens when we actually interact with objects and use the interface -that we are going to create in homework 4 -

but as we tested homework 3 with  TestNg , it does not seem to do such a thing , it only uses the data provided by the "sql" files , and the automatic id generation does not get involved here since we are just providing some non random id's (injecting to the database).

so the test lacking the integrity (in my opinion)

cysun
Posts: 2935
Posted 08:39 Oct 28, 2011 |
aligh1979 wrote:

There hes been a question / confusion regarding the automatic test in my mind . in hour home work what we do is to assign a "generated"  annotation to  ID fields in order to generate them automatically , and this automatic generation happens when we actually interact with objects and use the interface -that we are going to create in homework 4 -

No, the id value is automatically generated when you save a new object. When you create a new object, the id field is null, and after you save it, you can see that the id is no longer null. Note that because we are using entityManager.merge() to save an object, the "saved" object is the one returned by merge(), not the one you pass to merge().

but as we tested homework 3 with  TestNg , it does not seem to do such a thing , it only uses the data provided by the "sql" files , and the automatic id generation does not get involved here since we are just providing some non random id's (injecting to the database).

We didn't test saveRubric() in our tests so yes, id auto-generation is not tested.

so the test lacking the integrity (in my opinion)

I don't know what you mean by "integrity", but I'd agree that the tests are not comprehensive enough, or as the testing people would say, lack "coverage". There are several reasons for this: a) the purpose of the tests is to ensure your ORM mapping is correct and your DAO can connect to the database. More comprehensive testing is your job, not mine. b) I want to keep the test code simple so it does not give out how to implement the model classes. c) To keep the test code simple I want to use a pre-set id instead of an auto-generated one which could be different in different setups.