0

I'm not sure if should test static text for TDD for example email subject

for example I have the next piece of code is necessary add a test for including proper subject? or proper "from" param?

def send_mail_complete_sectors_and_profile():
    agents = Agents.objects.filter(
        Q(is_completed_profile=False) |
        Q(has_sectors_config=False)
    )
    agent_emails = map(lambda a: a.email1, agents)
    send_mail('', '', '', agent_emails);
Lino
  • 5,084
  • 3
  • 21
  • 39

1 Answers1

1

Kent Beck, 2008

I get paid for code that works, not for tests, so my philosophy is to test as little as possible to reach a given level of confidence

def send_mail_complete_sectors_and_profile():
agents = Agents.objects.filter(
    Q(is_completed_profile=False) |
    Q(has_sectors_config=False)
)
agent_emails = map(lambda a: a.email1, agents)
send_mail('', '', '', agent_emails);

i have the next piece of code is necessary add a test for including proper subject? or proper "from" param?

In this case, "yes, you should probably do that".

The motivation for writing the test is to improve your design. In particular, you want to end up with clean separation between core logic and side effects. If these concepts aren't familiar, see Gary Bernhardt's sceen cast, or a recording of his excellent talk Boundaries.

The promise of test first (an important element of ) is that we get a better understanding of the boundaries and the core by exploring deterministic logic first.

VoiceOfUnreason
  • 52,766
  • 5
  • 49
  • 91