3

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
        ->getObject('Vendor\Module\Test\Unit\Block\Catalog\Product\ProductList\Toolbar');
   }

   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"

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

1 Answer 1

4

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

With:

class ToolbarTest extends \PHPUnit_Framework_TestCase
2
  • My line 30 says: \Magento\Framework\View\Element\Template\Context $context,
    – Sushivam
    Commented Jun 22, 2016 at 5:49
  • My actual module works fine in development mode
    – Sushivam
    Commented 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.