menu_book Course Curriculum (Software Testing) expand_more
Testing Fundamentals
Assertions & Fixtures
Test Doubles & Dependencies
Coverage & Quality
API & Web Testing
dependency injection for testing
Learn dependency injection for testing in Software Testing with a dedicated explanation, a concept-specific example, practical cautions, and a mastery check.
12 min read
•
Intermediate
Advertisement
software-testing-020.py
python
def send_welcome(user, mailer): mailer.send(user['email'],'Welcome')
class FakeMailer:
def __init__(self): self.sent=[]
def send(self,to,subject): self.sent.append((to,subject))
m=FakeMailer(); send_welcome({'email':'a@x.com'},m); assert m.sent==[('a@x.com','Welcome')]
What to watch
Content source & attribution
Original Syntaxis Content · Original Syntaxis Content