Created
December 14, 2010 09:40
-
-
Save everzet/740190 to your computer and use it in GitHub Desktop.
Explanation in examples why PHP will never have RSpec-like behavioral unit tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RSpec (aka "Best in Ruby"): | |
@account.balance.should == 12 | |
# PHPUnit (aka "Best in PHP"): | |
$this->assertEquals(12, $account->getBalance()); | |
# PHPSpec: | |
$this->spec($account->getBalance())->should->be(12); | |
# Fabulous: | |
$w->valueOf($account->getBalance())->shouldBeEqualsTo(12); | |
# 1. Core difference here is in `$w->valueOf(...)` & `$this->spec(...)`. | |
# PHP doesn't have object inheritance, like Ruby or Java, so we | |
# need to wrap testing variables inside `spec` or `valueOf` | |
# 2. Second is `.` vs `->`. At the first, they looks the same, but | |
# in reality: | |
@account.balance.should... | |
# is way more human-readable plain text, than: | |
$account->balance->should... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think
.feature
files are way more readable ;-)