TDD Data Access Layer

In TDD, I have been testing business logic by simulating data access functions.
But in fact I also need to implement the layers below the business layer to make the application work properly.

Should I use TDD to implement the data access layer?
According to the discussion I have seen on the Internet, unit tests should not be connected to any external resources, such as databases, web services, etc. If they are connected, then they will become integration tests.

May I ask someone I understand this.

Thank you very much.

You are right

In TDD, I have been testing business logic by simulating data access functions.
But in fact I also need to implement the layers below the business layer to make the application work properly.

Should I use TDD to implement the data access layer?
According to the discussion I have seen on the Internet, unit tests should not be connected to any external resources, such as databases, web services, etc. If they are connected, then they will become integration tests.

May I ask someone I know something about this.

Thank you very much.

You are right, contact the outside world to make integration testing, but This connection is also important for testing. When using TDD, the contact surface should be as small as possible. This can be achieved by using a wrapper for each record or similar method.

Leave a Comment

Your email address will not be published.