emailing-and-texting-script
emailing-and-texting-script copied to clipboard
Create Tests
Didn't follow TDD on this one 😅. It works well thankfully, but it is ideal to have some tests.
Here are the test cases I can think of at the moment:
- Test that
getCommunicationObjects()
reads the JSON files well - Test that
dispatchCommunication()
is called at the right cron - Test that
sendSms()
inSmsSender
doesn't call Twilio for null or empty objects and for numbers that don't start with +234 - Test that
sendSms()
inSmsSender
is retried when there is an exception - Test that
sendEmail()
inEmailSender
doesn't call JavaMailSender for null or empty emails addresses or messages - Test that
sendEmail()
inEmailSender
is retried when there is an exception
Can I tackle the first test (getCommunicationObjects())?
Can I tackle the first test (getCommunicationObjects())?
@Keenal yes, you can!
What are we comparing the method with? Since the method's (getCommunicationObject()) return type is void, should we just check if the file exists? Or what should the objectMapper be returning? I wrote the test, I just need a correct answer to test it against.