We help IT Professionals succeed at work.
Get Started

Why bother with PHPUnit?

DrDamnit
DrDamnit asked
on
111 Views
Last Modified: 2016-01-30
Loaded question, I know. But, we recently started to implement PHPUnit with our new projects, and while it's neat to write the tests, they ALWAYS pass because I am testing how objects are instantiated or used in a vacuum. I am sure this is not the sum total of PHPUnit's abilities, and perhaps my answer is using mock objects. But, what I really want to test with PHPUnit is "What happens when a user violates the norms during the course of use? What will break?" i.e., what happens when a user acts like... a user?

Of course I need to ensure that when we instantiate a class of "Customer" the getBalance() method returns a number not null, and not a string. But there has to be more to it than that.

Can anyone give a short narrative on how they use PHPUnit to test more than: "Is this class written properly"?
Comment
Watch Question
Most Valuable Expert 2011
Author of the Year 2014
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE