The road so far….

April 7, 2013

Junit Recepies : Having common Setup and Teardown

Filed under: Agile, java — Tags: , — Rahul Sharma @ 7:56 pm

The other day I was refactoring one of our apis. We were removing some of the columns as they were not required. I believe in this exercise dropping the column was the most easy part. After that I removed the corresponding fields from the associated ORM and it was fine for the business related code.  But !! the big one, was my code was not compilable, as the object was being used in a lot of tests and thus my project was all painted RED.

While I was fixing all the required tests I realized most of the tests were on similar lines. We were pushing some data in tests, creating some required resources and then destroying them after the tests were done. Now we have blatantly copied the stuff in every testcase  with total disregard to the DRY principle. (more…)

Advertisements

May 13, 2010

EasyMock expectation(EasyMock.expect) flavours explained

Filed under: java — Tags: , — Rahul Sharma @ 10:29 pm

The EasyMock  framework for unit testing is quite powerful and has loads of mocking APIs for all purposes. One of the most important APIs for mocking is the createMock API. Using this we can create mock objects for a specified interface and then record and verify the method calls. Events are recorded in the IExpectationSetters, which can be created by the EasyMock.expect API. After creating the IExpectationSetters we can set the returned result/calling behavior using the different options available. (more…)