2
字符串我創建這個字符串如何使用PHPUnit測試
'Your maximum heart rate is ' . $int . ' Your body mass index is ' . $float . ' Your body fat percentage is ' . $float '%.'
,並返回其
我的說法是
$stringFormat = 'Your maximum heart rate is %d. Your body mass index is %f. Your body fat percentage is %f%.';
$this->assertStringMatchesFormat($stringFormat, $actualResultm, 'message');
,並在測試運行我得到這個錯誤
FatControllerTest::testBodyInfo
message
Failed asserting that format description matches text.
--- Expected
+++ Actual
@@ @@
-Your maximum heart rate is %d. Your body mass index is %f. Your body fat percentage is %f%.
+Your maximum heart rate is 193. Your body mass index is 43.181818181818. Your body fat percentage is 6.32302%.
現在我想象它必須與我告訴它期望一個unsigned int和兩個浮點數並返回一個長字符串的事實有關,但如果是這種情況,我該如何測試字符串,就像我列出的那樣有3個區域因案例而異?如果不是那麼那麼我做錯了什麼?
Grrr非常感謝所有這一切 – Ir1sh