Skip to Content
Former Member
Oct 05, 2016 at 01:39 PM

Code dependencies within the method



I am trying to write unit test for one method which is reading the data from database based on certain input.

For illustration purpose I am dividing my the code in the method into 3 sections.

METHOD <name>

"Section 1

< Here is the code which is building dynamic WHERE clause based on input, this WHERE clause is used in next

section to read the data from database. >

"Section 2

< As I said before, here I am writing the SELECT statement which is using the above WHERE clause >

"Section 3

< Processing of data fetched from Section 2 >


In order to write the unit test for the above method I was told by my fellow developer to simulate the code in section 2 (simulate Database access by certain techniques).

But If I bypass the code in section 2 by using any simulation techniques, I am also indirectly bypassing the section 1 because the simulated data is used in section 3.

How do i verify that section 1 is building the WHERE clause properly ?

Can any one please give some inputs ?

By the way this is my second unit test.