This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Testing Strategy

 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Sheriff
Pie
Posts: 2886
121
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 2886
121
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What domain functionality would you be testing for in this scenario?
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 2886
121
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic