I have created a file under \Vendor\Module\Test\Unit\Block\Catalog\Product\ProductList\Toolbar.php

namespace Vendor\Module\Test\Unit\Block\Catalog\Product\ProductList;
class Toolbar extends \PHPUnit_Framework_TestCase
   public function setUp()
    $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
    // we want this to be a real Magento 2 object
    // complete with all it's dependencies
    // so we use the object manager to get it
    $this->block = $objectManager

   public function testgetAvailableOrders()
   { .... }

My phpunit.xml is

 <testsuite name="Magento Unit Tests">
        <directory suffix="Test.php">../../../app/code/Vendor\Module /Test/Unit</directory>

Under magento 2 root, i ran

vendor/bin/phpunit -c dev/tests/unit/phpunit.xml app/code/Vendor\Module/Test/Unit/

I get "No tests executed"

  • Is there really a space in your phpunit.xml at Tglssearch /Test? Jun 21, 2016 at 12:46
  • No , there aint any space
    – Sushivam
    Jun 22, 2016 at 5:31

1 Answer 1


Well your phpunit.xml file specifies a suffix:

<directory suffix="Test.php">

So every tests you run must have this suffix and it doesn't seem like your test does.

To fix that, rename Tagalys\Tglssearch\Test\Unit\Block\Catalog\Product\ProductList\Toolbar.php to Tagalys\Tglssearch\Test\Unit\Block\Catalog\Product\ProductList\ToolbarTest.php

And replace:

class Toolbar extends \PHPUnit_Framework_TestCase


class ToolbarTest extends \PHPUnit_Framework_TestCase
  • My line 30 says: \Magento\Framework\View\Element\Template\Context $context,
    – Sushivam
    Jun 22, 2016 at 5:49
  • My actual module works fine in development mode
    – Sushivam
    Jun 22, 2016 at 6:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.