如何记录 PHPUnit 测试结果?
How do I document PHPUnit Tests Results?
除了使用 --testdox 进行记录之外,还有其他方法可以为我的 PHPUnit 测试提供更详细的报告吗?
也许不能直接回答您的问题,但您可以考虑使用像 Behat 这样的 BDD 框架。这些测试是用简单的人类语言编写的,因此它们表达了您的系统行为并且可以被非技术人员阅读。
示例来自 introducing BDD article:
Story: Account Holder withdraws cash
As an Account Holder
I want to withdraw cash from an ATM
So that I can get money when the bank is closed
Scenario 1: Account has sufficient funds
Given the account balance is $100
And the card is valid
And the machine contains enough money
When the Account Holder requests $20
Then the ATM should dispense $20
And the account balance should be $80
And the card should be returned
Scenario 2: Account has insufficient funds
Given the account balance is $10
And the card is valid
And the machine contains enough money
When the Account Holder requests $20
Then the ATM should not dispense any money
And the ATM should say there are insufficient funds
And the account balance should be $20
And the card should be returned
Scenario 3: Card has been disabled
Given the card is disabled
When the Account Holder requests $20
Then the ATM should retain the card
And the ATM should say the card has been retained
除了使用 --testdox 进行记录之外,还有其他方法可以为我的 PHPUnit 测试提供更详细的报告吗?
也许不能直接回答您的问题,但您可以考虑使用像 Behat 这样的 BDD 框架。这些测试是用简单的人类语言编写的,因此它们表达了您的系统行为并且可以被非技术人员阅读。
示例来自 introducing BDD article:
Story: Account Holder withdraws cash
As an Account Holder
I want to withdraw cash from an ATM
So that I can get money when the bank is closed
Scenario 1: Account has sufficient funds
Given the account balance is $100
And the card is valid
And the machine contains enough money
When the Account Holder requests $20
Then the ATM should dispense $20
And the account balance should be $80
And the card should be returned
Scenario 2: Account has insufficient funds
Given the account balance is $10
And the card is valid
And the machine contains enough money
When the Account Holder requests $20
Then the ATM should not dispense any money
And the ATM should say there are insufficient funds
And the account balance should be $20
And the card should be returned
Scenario 3: Card has been disabled
Given the card is disabled
When the Account Holder requests $20
Then the ATM should retain the card
And the ATM should say the card has been retained