locked
Unit testing through the class or through the interface? RRS feed

  • Question

  • Which one should I do?

    Create a unit test with the class method through the class or through the interface. What are the pros/cons of the two?

    If I have a project that is already deployed and I want to create some unit tests, should I start with creating methods from the interface or should I go to the class and start with creating tests from the methods through the class itself?


    chuckdawit
    Friday, August 5, 2011 8:46 PM

Answers

  • Since you want to test an implementation generally you will  create Unit Test Method Stubs from Class. But this also depends on your scenario.

    One Scenario where you may want to create Unit Tests From Interface is when you have explicit implementation of interface.


    Abhimanyu Singhal
    • Marked as answer by witdaj Monday, September 26, 2011 11:24 PM
    Thursday, September 22, 2011 7:43 AM

All replies

  • you should create unit test at the class level as contract's implementation will be at class level.

     

    Regards,

    Mittal.

    Monday, September 19, 2011 10:43 AM
  • Since you want to test an implementation generally you will  create Unit Test Method Stubs from Class. But this also depends on your scenario.

    One Scenario where you may want to create Unit Tests From Interface is when you have explicit implementation of interface.


    Abhimanyu Singhal
    • Marked as answer by witdaj Monday, September 26, 2011 11:24 PM
    Thursday, September 22, 2011 7:43 AM