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

Added the ability to configure additional paths for suite #6272

Open
wants to merge 1 commit into
base: 4.1
Choose a base branch
from

Conversation

olegpro
Copy link
Contributor

@olegpro olegpro commented Nov 5, 2021

Added the ability to configure additional paths for suite.

This allows you to focus tests closer to your code.

Example tests/codeception/unit.suite.dist.yml:

actor: UnitTester
bootstrap: _bootstrap.php
modules:
    enabled:
        - Asserts
        - \tests\codeception\Helper\Unit
        - Mockery
additional_paths:
    - src/backend/Model/*/*/Tests/

Example test file \App\Model\DeliveryDate\Calculator\Tests\MyTest:

<?php

declare(strict_types=1);

namespace App\Model\DeliveryDate\Calculator\Tests;

class MyTest extends \Codeception\Test\Unit
{
    public function testWithoutOrderCertificate(): void
    {
        $this->assertFalse(false);
    }
}

Example running test:

$ docker-compose run --rm php-cli vendor/bin/codecept run unit src/backend/Model/DeliveryDate/Calculator/Tests/MyTest.php

Codeception PHP Testing Framework v4.1.22
Powered by PHPUnit 9.5.10 by Sebastian Bergmann and contributors.

Tests\codeception.unit Tests (1) --------------------------------------------------------------------------------------------------------------------------------------------------
✔ MyTest: Without order certificate (0.00s)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Time: 00:00.026, Memory: 27.76 MB

OK (1 test, 1 assertion)

Tried adding tests but the current ones are broken. I would be glad to get help writing them.

@olegpro olegpro force-pushed the suite-additional-paths branch 2 times, most recently from ad785c3 to d1a3156 Compare November 5, 2021 20:46
@DavertMik
Copy link
Member

The idea is nice but all tests are failing. Could you fix them up?
If yes, I have no objections to the idea and implementation

@olegpro
Copy link
Contributor Author

olegpro commented Nov 18, 2021

The idea is nice but all tests are failing. Could you fix them up? If yes, I have no objections to the idea and implementation

@DavertMik Done.

@DavertMik
Copy link
Member

Wow, that was fast! Thanks!

@DavertMik
Copy link
Member

DavertMik commented Nov 19, 2021

I just figured out that additional_paths is not the best name here. How about just path: ?
This will make more sense if we provide an option to fully customize paths to tests.

So these options will be possible:

path: .

path: src/backend/Model/*/*/Tests

path:
  - .
  - src/backend/Model/*/*/Tests/

@olegpro what do you think of it? I think it will take minor changes in the code. If you are ok implementing it, I will write documentation.

@olegpro
Copy link
Contributor Author

olegpro commented Nov 19, 2021

@DavertMik good idea. I can try to implement.

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

Successfully merging this pull request may close these issues.

None yet

2 participants