2017 © Pedro Peláez
 

library annotation-processor

Utility for parsing constants from the description of the test methods. Created by tutu.ru

image

sakharovmaksim/annotation-processor

Utility for parsing constants from the description of the test methods. Created by tutu.ru

  • Thursday, June 28, 2018
  • by sakharov.maksim
  • Repository
  • 2 Watchers
  • 1 Stars
  • 286 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 122 % Grown

The README.md

Annotation Processor — utility for parsing constants from the description of test methods

Install

1. Download project from the repository

Navigate to the directory where you want to store the directory with project. For instance, your home directory cd ~., (*1)

git clone git@github.com:sakharovmaksim/annotation-processor.git, (*2)

And when downloading is done, navigate to the project directory cd annotation-processor., (*3)

2. Install dependencies

composer install, (*4)

Usage

1. In your TestCase class

In your TestCase class, in setUp() method, which extends from \PHPUnit\Framework\TestCase create and use function like:, (*5)

public function setUp()
{
    $this->_processAnnotations();
}

private function _processAnnotations()
{
    $class = get_class($this);
    $methodName = $this->getName(false);
    $annotationProcessor = new AnnotationProcessor($class, $methodName);
    // @domains
    if ($domainsExcept = $annotationProcessor->process(new Annotation\ArrayAnnotation(AnnotationsNames::DOMAINS_EXCEPT)))
    {
        if (Env::isRC() && in_array(Env::RC, $domainsExcept))
        {
            $this->markTestSkipped("Skip the test that is not for RC: {$class}::{$methodName}");
        }
        elseif (Env::isProduction() && in_array(Env::PROD, $domainsExcept))
        {
            $this->markTestSkipped("Skip the test that is not for Production: {$class}::{$methodName}");
        }
        elseif (Env::isStand() && in_array(Env::STAND, $domainsExcept))
        {
            $this->markTestSkipped("Skip the test that is not for stands: {$class}::{$methodName}");
        }
    }
    // @bug
    if ($annotationProcessor->process(new Annotation\BoolAnnotation(AnnotationsNames::BUG)))
    {
        $this->markTestSkipped("Skip the test {$class}::{$methodName}, because it has deactivated due to a @bug!");
    }
    // @todocase
    if ($annotationProcessor->process(new Annotation\BoolAnnotation(AnnotationsNames::TODOCASE)))
    {
        $this->markTestSkipped("Skip the test {$class}::{$methodName}, because it has @todocase, write it!");
    }
}

This function, when starting each test, will analyze the constants from the description and apply the actions described in the function above., (*6)

2. Create AnnotationsNames file with annotation constants

Use constants in _processAnnotations(), (*7)

class AnnotationsNames
{
    const DOMAINS_EXCEPT = '@domainsExcept';
    const BUG = '@bug';
    const TODOCASE = '@todocase';
}

3. Usage in tests annotations

/**
 * @labels Labels::RELEASE
 * @todocase Проверка поиска "Только туда"
 */
public function testSearchOW() {}

4. Run unit-tests for project

sh run_tests.sh, (*8)

5. Deploy

Travis CI run unit-tests for all Pull Requests. Look '.travis.yml'-file with CI-config, (*9)


Created by tutu.ru, (*10)

The Versions

28/06 2018

dev-master

9999999-dev

Utility for parsing constants from the description of the test methods. Created by tutu.ru

  Sources   Download

MIT

The Requires

 

by Sakharov Maksim

17/05 2018

1.0.3

1.0.3.0

Utility for parsing constants from the description of the test methods

  Sources   Download

MIT

The Requires

 

by Sakharov Maksim

17/05 2018

1.0.2

1.0.2.0

Utility for parsing constants from the description of the test methods

  Sources   Download

MIT

The Requires

 

by Sakharov Maksim

16/05 2018

1.0.1

1.0.1.0

Utility for parsing constants from the description of the test methods

  Sources   Download

MIT

The Requires

 

by Sakharov Maksim

16/05 2018

1.0.0

1.0.0.0

Utility for parsing constants from the description of the test methods

  Sources   Download

MIT

The Requires

 

by Sakharov Maksim