Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore entire folders in settings file #28

Open
metheoryt opened this issue Sep 19, 2014 · 2 comments
Open

ignore entire folders in settings file #28

metheoryt opened this issue Sep 19, 2014 · 2 comments

Comments

@metheoryt
Copy link

Is there a way to ignore some folders in project, like pageObject and stepObject folders?

@YOzaz
Copy link

YOzaz commented Jun 5, 2015

+1 to this one. Currently, Webception theats StepObjects and PageObjects like tests - which is incorrect, only Cests/Cepts should be.

@YOzaz
Copy link

YOzaz commented Jun 5, 2015

Actualy, it's quite easy to fix. Taken from here: http://stackoverflow.com/a/20501275
App\Lib\Codeception.php, method loadTests:

$exclude = $this->config['ignore'];
/**
 * @param \SplFileInfo $file
 * @param mixed $key
 * @param \RecursiveCallbackFilterIterator $iterator
 * @return bool True if you need to recurse or if the item is acceptable
 */
$filter = function ($file, $key, $iterator) use ($exclude)
{
    if ($iterator->hasChildren() && !in_array($file->getFilename(), $exclude))
    {
        return true;
    }
    return $file->isFile();
};

$files = new \RecursiveIteratorIterator(
    new \RecursiveCallbackFilterIterator(
        new \RecursiveDirectoryIterator(
            "{$this->config['paths']['tests']}/{$type}/",
            \FilesystemIterator::SKIP_DOTS
        ),
        $filter
    ),
    \RecursiveIteratorIterator::SELF_FIRST
);

Then this part is not required, as will be filtered in iterator:

if (! in_array($file->getFilename(), $this->config['ignore']) && $file->isFile()) {

Now you can include directories in codeception.php ignore as well:

'ignore' => array(
    'WebGuy.php',
    'TestGuy.php',
    'CodeGuy.php',
    '_bootstrap.php',
    '.DS_Store',
    '_pages',
    '_steps',
),

N.B. _pages and _steps are standard namings from Codeception native generator for PageObjects and StepObjects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants