• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Testing Strategy

 
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic