I have an El Cap Virtualbox VM and when I run the tests on my code they fail, whereas on a non-VM install the tests pass. The failure comes down to SecPKCS12Import
failing with the error: The user name or passphrase you entered is not correct.
Of course the password is the same and correct, or the tests would not work on the non-VM install. This is also not an issue with using ssh as I can run the tests remotely using ssh on the non-VM install and they pass just fine.
Turns out that you have to manually unlock the keychain with: security unlock-keychain -p $PASSWORD ~/Library/Keychains/login.keychain
before running the tests on a VM.