Running a single PhpUnit test

Well, we all love tests :). There are times we would like to run a single test that has failed so that we can fix or look at it thoroughly.
The problem, when you are running

phpunit -c /testFolder..

All tests would run.
The fix..
Let’s assume you have this particular test in one of your test files

public function testPhpIsAwesomeOrNot(){

All you have to do is to add the group annotation above the function

 * @group awesome
public function testPhpIsAwesomeOrNot(){}

then run it with –group
phpunit -c /testfolder –group awesome


Wanted but not invoked: However, there were other interactions with this mock: ->

Wanted but not Invoked Error in mockito and its solution

This happens with mockito when trying to verify the invocation on an object with specific method.

But what happens is you have interacted with other method of that object but not the one mentioned.

If you have an object named CustomerService and say it has two methods named saveCustomer() and verifyExistingCustomer()

And mockito looks something like

verify(customerService, atleast(1)).verifyExistingCustomer(customer), 

But in your actual service you called the saveCustomer() at least once.. BINGO you would get that error.

Also Recommended for you

See how you can get started with mockito with simple example

Do you like Algorithms?

Find K complementary numbers from given array

Can you form the longest palindrome from the given random characters?