Geeks With Blogs

News Ashraful Alam Joy

Create Your Badge

Ashraful Alam is a Software Architect, who has 8 years of professional experience in Software Development industry. This Bangladeshi national is involved with project management and development of several US based software projects from his country. Already he has managed and developed several software projects, which are being used by several users of different countries, such as USA, Canada, Australia, and Bangladesh. While developing and managing a team, he contains and maintains a set of well defined engineering practices developed by him and other online developer communities.

Due to his willingness to give effort to improve and share better software development practices, Ashraf has been awarded as “Most Valuable Professional” (MVP) in ASP.NET category by Microsoft since year 2007 multiple times, which is a rare honor and prestigious reorganization among the developers around the world.

Check his portfolio to know more about him and his works.

.NETTER Characters... Every part of your life is best, if you can know yourself and thus create your life like an artist!



Software Designers often have to face a common decision factor, that whether they need to design automated test (unit test, integration test etc) infrastructure for data access layer code, specially when the data access layer codes are written using code generator tool. Basically the straight forward answer as ‘Yes’ or ‘No’ in this regard depends of several situations/ factors such the size and budget of the project etc. Here are my 5 top reasons to write automated test (unit test, integration test etc) for generated data access layer code.

1. When the code generation template/logic itself contains bug

While using the code generators, it’s possible that the underlying code/logic of the code generators may contain bug! Having the automated test for the generated data access layer code greatly helps of indentify the ‘generated’ bugs!

2. When the code is not re-generated after to change of underlying database object

Well I swear my generated code engine is perfect (i.e. no bug on my generator engine/template logic)! Cool. I have generated the code perfectly. However I have changed the underlying database, but really forgot to re-generate the code using the code generator! Well that could be possible and can be detected if we have corresponding automated tests!

3. When the re-generated code is not perfect for the new changes of underlying database object

Well I swear my code has been re-generated after I have changed by database. Cool. But the initial version of generated code may work perfectly with the initial version of database objects. However, new bugs can be found/introduced in the generated code for the new changes of underlying database objects, which results updating the code generation logic. So, still you need automated tests for your data access layer code!

4. When custom code is added in the generated code

Sometimes custom code needs to be placed on the generated code. In those cases automated tests really helps a lot of indentify the bugs possibly placed in custom code in data access layer and/or in database stored procedure, function etc.

5. To check the perfect integration with database objects

Even the codes are generated/written for data access layer perfectly, but it’s still possible of failing the code running properly while the data access layer code and database objects are integrated. For instance using wrong connection string that points to wrong version of database etc. Having a well designed automated testing infrastructure really helps us in this regard!

Posted on Thursday, February 26, 2009 2:33 PM Testing | Back to top

Comments on this post: 5 Reasons to Write Automated Tests for Generated Data Access Layer Code

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Ashraf Alam | Powered by: