#JavaMailSender Unit Tests
1 messages · Page 1 of 1 (latest)
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
it'll be very difficult to mock the correct parts, I'd suggest not testing this at all or add a return type to your method with a result
or send to self and check if it recieves
You shouldn't have an active smtp server for a unit test, unless there's a lib in Java for it then a call to localhost might work
@hasty ember do you have the place where you make the JavaMailSender handy?
its just an interface
so hypothetically you can make an implementation that doesn't do anything
and then construct your class with that implementation
two ways to do that
- Just make it
class FakeMessageSender implements EmailSender {
@Override
public MimeMessage createMimeMessage() {
// ...
}
// ...
// and so on
}
- Use a library which can make a proxy for you like mockito
1 is probably what I would do with
at least for this interface