为每次测试运行提供隔离邮箱

QA 与测试

为每个测试创建唯一的邮箱地址。验证注册流程、密码重置和事务性邮件,避免共享邮箱的污染问题。

核心功能

  • 每个测试用例使用唯一地址
  • 轮询 API 便于 CI/CD 集成
  • 对邮件内容进行断言
  • 测试后自动清理

示例

# RSpec example
describe "User signup flow" do
  it "sends verification email" do
    # Create unique inbox for this test
    inbox = Mailhook.create_random_address

    # Trigger signup in your app
    user = create(:user, email: inbox.address)
    UserMailer.verification(user).deliver_now

    # Assert email was received
    emails = Mailhook.poll_inbox(inbox.id)
    expect(emails.count).to eq(1)
    expect(emails.first.subject).to include("Verify")

    # Extract verification link
    link = emails.first.text_body.match(/https?:\/\/\S+/)[0]
    expect(link).to include("/verify")
  end
end

准备好开始了吗?

60 秒内创建您的第一个邮箱。