my dog learned polymorphism*
The moose likes JDBC and the fly likes Testing Strategy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Testing Strategy" Watch "Testing Strategy" New topic
Author

Testing Strategy

Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 590

This test seems to be non-sense because every time the id will be different.
What is the general usage of JUnit of this kind of situation?
It seems to make sense only when it takes on some value and transforms and returns something meaningful
Thanks
Jack
Tim Cooke
Bartender

Joined: Mar 28, 2008
Posts: 971
    
  47

Perhaps in cases like this you are not so much interested in the actual value of the employee ID, rather you are interested in whether the generated ID is unique or follows some pattern that you expect.

- Let's say the ID generation is random. You probably want to test that multiple calls return different ID's each time with no dups.
- Let's say the ID generation is sequential: You may want to test that the next ID val is some increment larger than the previous.
- Let's say the ID generation is in some way deterministic: You would then be able to predict the returned value and test for it explicitly.


Tim Driven Development
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 590
Tim Cooke wrote:Perhaps in cases like this you are not so much interested in the actual value of the employee ID, rather you are interested in whether the generated ID is unique or follows some pattern that you expect.

- Let's say the ID generation is random. You probably want to test that multiple calls return different ID's each time with no dups.
- Let's say the ID generation is sequential: You may want to test that the next ID val is some increment larger than the previous.
- Let's say the ID generation is in some way deterministic: You would then be able to predict the returned value and test for it explicitly.


I wonder, if I first generate a timestamp in Java. Then query the database for another one, then as there are some time differential between java and sqlite, how
can I make sure the test case is correct?
Thanks
Jack
Tim Cooke
Bartender

Joined: Mar 28, 2008
Posts: 971
    
  47

What domain functionality would you be testing for in this scenario?
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 590
Tim Cooke wrote:What domain functionality would you be testing for in this scenario?


Looks like the logo has been changed,
that aside, what is a domain funcationality?
I am working on a CRM, temporarily I allow
the user to input transaction, employee and sales information manually etc.
The id composes of a serial, stored separately in a table,
and a timestamp separated by a hyphen, when the operator
creates an employee, the serial is incremented and concatenated with the
timestamp...

Tim Cooke
Bartender

Joined: Mar 28, 2008
Posts: 971
    
  47

"Domain" refers to the scope and purpose of your application and business requirements. So when I ask what domain functionality you are testing, I mean what requirement of your application are you testing?

In your example you're asking about having a test that will do some comparison between a timestamp created in Java and a timestamp created in your database. While it is understood that these two may not be the same, what is the purpose of writing a Unit Test to check? As you're working with a CRM system, then your domain is CRM. Is it a requirement of CRM systems in general that your application and database system times are in sync? No, that is an implementation detail, a technical integration consideration. It may be a requirement that your recorded timestamps are consistent and verifiable, in which case you may want to consider using a single source of timestamps to avoid these sorts of physical system sync problems altogether.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Testing Strategy