My problem is: i have a function triggered by a daily Timer that is supposed to send emails to a list of addresses stored in a database, even the text of the email is an array of datas retrieved by queries in a database. The function doesn't have inputs, nor outputs (if we don't consider the text of the email, that is directly sent by the function). How am i supposed to create a set of blackbox test cases for something like this?
Asked
Active
Viewed 434 times
1 Answers
0
There are at least two ways of writing tests for these code.
You can use an in-memory database and an in-memory IMAP- or SMTP-server. Add data to the database. Configure your function to use that database and the email server. Run your function and check the inbox of the email server.
You can mock the database and the emailserver and inject them into the function's class.

Stefan Birkner
- 24,059
- 12
- 57
- 72