• 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

Interfaces in TDD

 
Ranch Hand
Posts: 1402
3
  • Number of slices to send:
    Optional 'thank-you' note:
Hi @ll,

having this Class:



I want to use TDD. I am finding out how to create TDD tests for classes with interfaces. I have searched on the web for a while but I find it confusing.

Could someone, give a resource where I could get clear examples or info, please?

Regards, ISaac
 
Sheriff
Posts: 17652
300
  • Number of slices to send:
    Optional 'thank-you' note:
What exactly do you mean when you say "I want to create TDD tests"?

TDD is an approach, a way of thinking about design and code. It's not an adjective as you have used it.
 
Sheriff
Posts: 5555
326
  • Number of slices to send:
    Optional 'thank-you' note:
You've jumped the gun already with TDD because you've written some implementation without writing a test first. TDD stands for Test Driven Development which discusses a method of programming where your tests drive your implementation which implies you write your tests first.

You'll have probably found already a whole bunch of information about TDD on the internet, some proposing it, some condemning it, and lots of conflicting information in-between. My recommendation to grasp the original essence of TDD without getting clouded by all the chaff that followed is to pick yourself up a copy of Kent Beck's "Test-Driven Development by Example". The book is from way back in 2003 but don't be put off, it's a great read.
 
Angus Ferguson
Ranch Hand
Posts: 1402
3
  • Number of slices to send:
    Optional 'thank-you' note:
Yes, I meant that I am following TDD for the desing of a small app, and I would like to have feed back, because I need to add Interfaces in order to implement the Comparator interface....
 
Angus Ferguson
Ranch Hand
Posts: 1402
3
  • Number of slices to send:
    Optional 'thank-you' note:
Ok I get the book!
 
Junilu Lacar
Sheriff
Posts: 17652
300
  • 1
  • Number of slices to send:
    Optional 'thank-you' note:
No knock on Kent Beck's book but IMO the best book that will help you understand and get better at TDD is a one that's not explicitly about TDD: Corey Haines "Understanding the 4 Rules of Simple Design"

If you're a beginner, I doubt you'll find anything specifically about testing interfaces in either book though. I think that's a nuance that you'll only recognize when you understand how TDD is supposed to be done. Here's my take on testing interfaces:

1. Tests that are written against an interface will be "abstract" by nature because interfaces are not executable, unless your interface has default methods as introduced in Java 8.  Generally, however, the tests you define for an interface should pass when run against any and all current and future implementations.

2. Following from #1, you'd probably want to set up a unit test for an interface's API as an abstract class that will be extended by tests that provide a specific implementation.

I don't see the code that you provided as being specifically tied to a test around an interface.  I would probably write tests like this:


As I said, TDD is a way to think about design and drive that thinking with tests.  These tests would probably make me think about the need to implement equals() and hashcode() since it would be surprising to have a compareTo() that is based on # of likes but still have equals() be inherited from Object, which only checks for reference equality -- there's a lack of symmetry there that should be address to make the BioPic class more complete and avoid surprises later on.
reply
    Bookmark Topic Watch Topic
  • New Topic
vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |