Installing PHPUnit can be a little bit complicated with MAMP specially if you were running through incompatible versions.
I got it running after twisting my mind for many hours searching, so it deserves a full tutorial.
You’ll install PHPUnit using “Pear” installer and we’ll use the one that came with MAMP not the one with Mac OSX. The installation will take place in the command line so go ahead and open Applications -> Utilities -> Terminal
All the commands supplied down “should” work perfectly for you just copy and run.

00- As you’re using bin files from MAMP so the trick is to use the full path of the bin file:
/Applications/MAMP/bin/php5.3/bin/pear
Also whenever you have a message referring to permission denied or couldn’t run command, just try the same code with admin access by adding “sudo” before them and entering your “Password:” when asked.
Also to notice it’s better if you do the next with MAMP servers closed.

01- When you first get MAMP 1.9.4 you’ll have Pear 1.9.0 with it, but Pear 1.9.1 is needed, I tried the next commands:

sudo /Applications/MAMP/bin/php5.3/bin/pear upgrade pear

After supplying the password I was given the next message:

warning: pear/Console_Getopt requires PEAR Installer (version >= 1.9.1), installed version is 1.9.0

now you try something like:

sudo /Applications/MAMP/bin/php5.3/bin/pear upgrade pear/Console_Getpot

again it will notify that upgrading failed because it depends on Console_Getpot 2.6.something.

so it was a dead lock to me even offline install didn’t work, I got the offline package placed it in /Applications/MAMP/bin/php5.3/bin/pear/:

sudo pear install --offline /Applications/MAMP/bin/php5.3/bin/pear/PEAR-1.9.1.tgz

Now although the above commands didn’t work for me but many online guys said it did for them so I just wanted to include them, so let’s see what actually worked for me. Open http://pear.php.net/go-pear and you’ll have a php code in front of you, save it as go-pear.php and save it into:
/Applications/MAMP/bin/php5.3
first you’ll have to have read/write permissions over bin/php if you’re not logged in as root user:

chmod 774 /Applications/MAMP/bin/php5.3/bin/php

okay now that you’ve got permissions let’s execute the go-pear.php:

/Applications/MAMP/bin/php5.3/bin/php go-pear.php

You’ll see messages and confirmations so just press enter when needed and answer “yes” or “no” when asked, even if you didn’t understand don’t worry nothing serious just extra packages. You might also get a bunch of deprecated messages as well, it’s just fine.

now you have “Pear 1.9.1″ installed, and a new folder called “PEAR” in /Applications/MAMP/bin/php5.3

test the version of your pear:

/Applications/MAMP/bin/php5.3/bin/pear version

Note: At some points I had this error when trying to run pear after installing:

"/Applications/MAMP/bin/php5.3/bin/pear: line 28: /Applications/MAMP/bin/php5.3/lib/php: is a directory"

Simply navigate to pear bin file “/Applications/MAMP/bin/php5.3/bin/” right click on it and “open with” choose a syntax highlighter program something like BBEdit and you’ll see this snippet of code:

else
    if test "/Applications/MAMP/bin/php5.3/lib/php" = '@'php_bin'@'; then
        PHP=php
    else
        PHP="/Applications/MAMP/bin/php5.3/lib/php"
    fi
fi

just make sure you change the /lib to /bin

else
    if test "/Applications/MAMP/bin/php5.3/bin/php" = '@'php_bin'@'; then
        PHP=php
    else
        PHP="/Applications/MAMP/bin/php5.3/bin/php"
    fi
fi

save and run your command again it should work.

02- Now to what we’ve came here for, PHPUnit. grant permission of read/write to your PEAR and discover channels to download and install phpunit from:

chmod 774 /Applications/MAMP/bin/php5.3/bin/pear

discovering channels:

sudo /Applications/MAMP/bin/php5.3/bin/pear channel-discover pear.phpunit.de

sudo /Applications/MAMP/bin/php5.3/bin/pear channel-discover pear.symfony-project.com

sudo /Applications/MAMP/bin/php5.3/bin/pear channel-discover components.ez.no

03- Your PEAR installer should be ready now, run the next:

sudo /Applications/MAMP/bin/php5.3/bin/pear install phpunit/PHPUnit

This last command would take some time so just hold on until the download and install finishes.

04- Again if you try to run:

/Applications/MAMP/bin/php5.3/bin/phpunit

you’ll get the next:

“unable to execute /Applications/MAMP/bin/php5.3/bin/phpunit: Permission denied”

even with sudo it didn’t work, just navigate to “/Applications/MAMP/bin/php5.3/bin” and right click “phpunit”, open it for editing, at first line you’ll see this:

#!/Applications/MAMP/bin/php5.3/lib/php

change it to:

#!/Applications/MAMP/bin/php5.3/bin/php

scroll down to see this line:

if (strpos('/Applications/MAMP/bin/php5.3/lib/php', '@php_bin') === 0) {

change @php_bin to /Applications/MAMP/bin/php5.3/bin/php

if (strpos('/Applications/MAMP/bin/php5.3/lib/php', '/Applications/MAMP/bin/php5.3/bin/php') === 0) {

05- Now grant your “phpunit” permissions:

chmod 774 /Applications/MAMP/bin/php5.3/bin/phpunit

checking the version:

/Applications/MAMP/bin/php5.3/lib/phpunit -v

will indicate that it’s PHPUnit 3.5.10.

06- Finally to use your “phpunit” command without the need of the full path, it’s a good practice to copy the “phpunit” file to your usr/local/bin

sudo cp /Applications/MAMP/bin/php5.3/bin/phpunit /usr/local/bin/

Now you can simply use:

phpunit -v

And that’s it.

Although it’s kind of tricky process, but it worth it at the end to follow a TDD (Test-driven Development) methodology, it saves a lot of time when your application modules grow big.

Hopefully this tutorial helped you continue, comment if you see any changes needed or any extra steps.

Resources:
PEAR Download
Checking if PEAR works
PHPUnit source files (For Manual Installation)
Official “Installing PHPUnit”