Search code examples
unit-testingdesign-patternstestingintegration-testingfunctional-testing

Testing similar logic


I am really curious as to how to best test a small project that may be developed.

enter image description here

Consider the above design pattern. Is there a good way to test a software that follows the above design. I have forms to add contact, event, jobs and other details that uses such design. For example to add a Contact, a ContactDAO will creates and uses a ContactDTO to update or add data to the data source. This flow has been also applied to event, job and other type. (event uses EventDAO and EventDTO).

What would be the best way to test such systems. I come across object-oriented testing. could that be used?

maybe other testing techniques?

Ofcourse while implementing, we use debugging which is a form of component testing. I am curious about the documentation of testing. Is there a good way to document testing of system where several types use similar logic.


Solution

  • In my opinion there are 3 ways you should test your code

    • Unit testing: Create your code so it is possible to take each class you want to test and mock out all dependencies. This way you can verify every functionality of that specific block

    • Integration tests: This is a Unit test that setups your code as-if it is really running whith a test database and so on. Then perform your actions on the highest level possible and do your verification on the values returned or the data that is changed

    • Last but not least: Create test scenario's, these scenarios can be manually tested and should consist of all required functionality. This way you are able to manually reproduce these test on a similar way.

    This way of testing can be applied to all projects, but you will have to keep this into account writing your code so it will remain testable.