• 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Issue with hamcrest test matching.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am currently getting an error when trying to match car objects in my tests (even though they look identical).
Please see attached files for error.
I currently have the following testing class:



And the following JDBCDAO class:



Capture4.PNG
[Thumbnail for Capture4.PNG]
Capture3.PNG
[Thumbnail for Capture3.PNG]
 
Marshal
Posts: 72913
330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

We have moved you to our testing forum.
Please copy'n'paste the error messages; I can't read your screenshots, and please explain what the problem is.
 
Saloon Keeper
Posts: 12990
281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post your Car class.

Please post the full error message as text.
 
Sheriff
Posts: 22207
117
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your hasItem and hasItems matchers rely on the equals method of class Car. Does it have one?

If not, and you can't add one, then you can make use of nested matchers. For instance:

To avoid all that duplication you can create a factory method for the car matcher:
 
reply
    Bookmark Topic Watch Topic
  • New Topic