Unittest

Unit tests are runned with magento dev:tests:run <test> and is used to test your code in development.

  • Test suite: A class with a collection of tests
  • Test name: The name of a test

Use the Unittest snippet in the Magento 2 module creator.

Files

Test/Unit/TestTest.php

<?php


namespace Mage2Gen\Module\Test\Unit;

class TestTest extends \PHPUnit_Framework_TestCase
{

    /**
     * Is called once before running all test in class
     */
    public static function setUpBeforeClass()
    {
        //setup
    }

    /**
     * Is called once after running all test in class
     */
    public static function tearDownAfterClass()
    {
        //teardown
    }

    /**
     * Is called before running a test
     */
    protected function setUp()
    {
        //setup
    }

    /**
     * Is called after running a test
     */
    protected function tearDown()
    {
        //teardown
    }

    /**
     * The test itself, every test function must start with 'test'
     */
    public function testTest()
    {
        $this->assertTrue(false);
    }
}