Hi
Sorry for not expressing myself clearly :oops:
In order to give you a better help I need to see the production code not the test code.
In your case it will be the code that handle the data base.
What is method that create the data base? (I did not understand if you are using the csv file only in the test or in the production code.)
What is method that get the data from the data base?
etc..
I'll try to guess base on what you posted here.
First you have to decide if you want to do integration test or unit test.
If you are doing integration test you want to create and read from the data base so you will not use mocking.
If you are trying to do unit tests you want to abstract the data base layer and use mocking.
So what have to do is that:
1. Mock the creation of the data base:
2. Mock the connection to the data base.
3. Mock the return value from the query.
4. Mock mail sender. (you don't want to send real mail)
5. check the mail content for the password.
Note that usually you will use the Assert class to check the expected results instead of an if clause.
In order to give you more details I'll need at least the classes names and methods signatures from the production code.
:arrow: You can take a look at
this blog post which talks also about data base mocking.