Testing Code Using Serialized Objects

After having written few new methods to enhance a functionality, I needed to test the code. Now the app requires dataset, binning library and various groovy nodes for initialization.  Also it does a lot of pre-processing. So there were two options for me -

  • Hack the code to insert special test methods at a particular point.
  • Write a test class which does all the initializations and then runs the app

I did not want the run the whole app. All I wanted to test was if my methods were running fine on one iteration or not. I did not want to wait for 10 minutes to wait for the algorithm to complete and then look at the log files to see the impact.

What I did was serialization of all the objects required by my methods. It required me to hack the code and write a few lines serializing the various maps, data structures and stuffs. But with that done, all I now need to do is to deserialize these objects and get whatever I need to test my methods.

Simple! I can now write small, neat methods whose purpose is only to test the particular methods without running the whole algorithm.

Popularity: 2% [?]

Related posts:

  1. My Code Rules – Code Documentation Check
  2. And Then The Coding Begins
  3. Electronic Code Book
  4. Trying To Get AST Working … I
  5. Java Code: Pair Class

blog comments powered by Disqus