1. Go to this page and download the library: Download polozpavlo/allure-phpunit library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
polozpavlo / allure-phpunit example snippets
namespace Example\Tests;
use PHPUnit\Framework\TestCase;
use Yandex\Allure\Adapter\Annotation\Title;
/**
* @Title("Human-readable test class title")
*/
class SomeTest extends TestCase
{
/**
* @Title("Human-readable test method title")
*/
public function testCase()
{
//Some implementation here...
}
}
namespace Example\Tests;
use PHPUnit\Framework\TestCase;
use Yandex\Allure\Adapter\Annotation\Description;
use Yandex\Allure\Adapter\Model\DescriptionType;
/**
* @Description("Detailed description for test class")
*/
class SomeTest extends TestCase
{
/**
* @Description(value = "Detailed description for <b>test class</b>.", type = DescriptionType::HTML)
*/
public function testCase()
{
//Some implementation here...
}
}
namespace Example\Tests;
use PHPUnit\Framework\TestCase;
use Yandex\Allure\Adapter\Annotation\Severity;
use Yandex\Allure\Adapter\Model\SeverityLevel;
class SomeTest extends TestCase
{
/**
* @Severity(level = SeverityLevel::MINOR)
*/
public function testCase()
{
//Some implementation here...
}
}
namespace Example\Tests;
use PHPUnit\Framework\TestCase;
use Yandex\Allure\Adapter\Annotation\Parameter;
use Yandex\Allure\Adapter\Model\ParameterKind;
class SomeTest extends TestCase
{
/**
* @Parameter(name = "param1", value = "value1")
* @Parameter(name = "param2", value = "value2", kind = ParameterKind::SYSTEM_PROPERTY)
*/
public function testCase()
{
//Some implementation here...
}
}
namespace Example\Tests;
use PHPUnit\Framework\TestCase;
use Yandex\Allure\Adapter\Annotation\Features;
use Yandex\Allure\Adapter\Annotation\Stories;
/**
* @Stories({"story1", "story2"})
* @Features({"feature1", "feature2", "feature3"})
*/
class SomeTest extends TestCase
{
/**
* @Features({"feature2"})
* @Stories({"story1"})
*/
public function testCase()
{
//Some implementation here...
}
}
namespace Example\Tests;
use PHPUnit\Framework\TestCase;
use Yandex\Allure\Adapter\Support\AttachmentSupport;
class SomeTest extends TestCase
{
use AttachmentSupport;
public function testCase()
{
//Some implementation here...
$filePath = $this->outputSomeContentToTemporaryFile();
$this->addAttachment($filePath, 'Attachment human-readable name', 'text/plain');
//Some implementation here...
}
private function outputSomeContentToTemporaryFile()
{
$tmpPath = tempnam(sys_get_temp_dir(), 'test');
file_put_contents($tmpPath, 'Some content to be outputted to temporary file.');
return $tmpPath;
}
}
namespace Example\Tests;
use PHPUnit\Framework\TestCase;
use Yandex\Allure\Adapter\Support\StepSupport;
class SomeTest extends TestCase
{
use StepSupport;
public function testCase()
{
//Some implementation here...
$this->executeStep("This is step one", function () {
$this->stepOne();
});
$this->executeStep("This is step two", function () {
$this-stepTwo();
});
$this->executeStep("This is step three", function () {
$this->stepThree('someArgument');
});
//Some implementation here...
}
private function stepOne()
{
//Some implementation here...
}
private function stepTwo()
{
//Some implementation here...
}
private function stepThree($argument)
{
//Some implementation here...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.