python - 应该测试 tdd 的静态文本,例如电子邮件主题?

标签 python unit-testing testing automated-tests tdd

我不确定是否应该测试 TDD 的静态文本,例如电子邮件主题

例如,我有下一段代码是否有必要添加一个测试以包含正确的主题?或适当的“来自”参数?

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);

最佳答案

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?

在这种情况下,“是的,您可能应该这样做”。

编写测试的动机是改进您的设计。特别是,您希望最终将核心逻辑和副作用完全分离。如果您不熟悉这些概念,请参阅 Gary Bernhardt 的 sceen cast , 或他精彩演讲的录音 Boundaries .

测试优先( 的一个重要元素)的 promise 是,我们通过首先探索确定性逻辑来更好地理解边界和核心。

关于python - 应该测试 tdd 的静态文本,例如电子邮件主题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51867106/

相关文章:

unit-testing - 如何对具有关系映射的 grails 域类进行单元测试?

django - 在 Django 中适当放置属于非应用程序的测试用例

php - 尝试使用 Codeception 和 Yii2 接受 native js 弹出窗口时出错

python - 在 Python 中不在括号内的空格上拆分

python - 如何根据 Python 中的日期(而不是当前语言环境)将 DateTime 转换为夏令时

python - 带有 predict_proba 的 SGDClassifier

java - TestNG 有条件地运行测试多次

python - 是否有任何 python 或 scala 工具来连接 spark/shark

unit-testing - 对 Firebase : what's the "right way" to test/mock `transaction` s with sinon. js 的 Cloud Functions 进行单元测试

带有 bUnit 的 C# Blazor 测试表单