• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to start Unit Testing and Integration testing with an existing code base

 
Francis Zabala
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello to all,

I recently developed a web service. It was done in a hurry so I wasn't able to create unit tests. I now have the time to refactor it and want to create some unit test and integration tests. What I am planning to do is create an integration test. I plan to create something that would simulate how the data passes from the mobile application to the web service and back. I recorded the json (jsons?) and plan to use them as my control while doing some refactoring. The web service is using HTTP to receive json and returns the results as a json.

Anyway, what tools do you guys use? Do you have the same process like what I intend to do? Is what I am planning wrong, waste of time and just hastens the heat death of the universe?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35716
410
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Francis,
Sounds like a good plan. For legacy code, it is often easier to start with an integration test. That gives you some safety to refactor to facilitate unit testing. (Michael Feathers defines legacy code as any code which was originally written without tests. Even if you wrote it 2 days ago. His book "Working Effectively With Legacy Code" is excellent by the way.)

I use JUnit with HtmlUnit to test web services. Another alternative is to use JUnit with Spring's RestTemplate for testing the web services.
 
Francis Zabala
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne,

Thank you for your feedback and am really glad that I can avoid shooting my own foot with my plan. I really like what defines a legacy code now. Hahaha!

Regards,
Francis
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!