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 snippet in the Magento 2 module creator.
Files
Test/Unit/TestTest.php
<?php
declare(strict_types=1);
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);
}
}