gerardroche / sublime-phpunit

PHPUnit Sublime Text integration.
https://www.gerardroche.com
GNU General Public License v3.0
74 stars 11 forks source link

Add replace phpunit command option #106

Closed amirHossein5 closed 1 year ago

amirHossein5 commented 1 year ago

Add phpunit.replace_phpunit_cmd_if_key_exists option, to run $WORK_DIR/artisan, test, or running tests from project script.

But there are two issues:

Screenshot from 2023-04-09 13-26-04

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 8.33% and project coverage change: -0.49 :warning:

Comparison is base (d84d714) 46.64% compared to head (a441f76) 46.15%.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #106 +/- ## ========================================== - Coverage 46.64% 46.15% -0.49% ========================================== Files 1 1 Lines 551 559 +8 ========================================== + Hits 257 258 +1 - Misses 294 301 +7 ``` | [Impacted Files](https://codecov.io/gh/gerardroche/sublime-phpunit/pull/106?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Gerard+Roche) | Coverage Δ | | |---|---|---| | [plugin.py](https://codecov.io/gh/gerardroche/sublime-phpunit/pull/106?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Gerard+Roche#diff-cGx1Z2luLnB5) | `46.15% <8.33%> (-0.49%)` | :arrow_down: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Gerard+Roche). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Gerard+Roche)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

gerardroche commented 1 year ago

See #102 and #103 on why there are some issues with running tests via test runners like artisan.

I wouldn't want the artisan test runner or any other test runner to replace the PHPUnit runner by default.

Test runners like artisan and pest are essentially wrappers around the PHPUnit runner. They generally work the same as PHPUnit with all the options and functionality except they add some functionality, sometimes change the default options, and have different styled output. The phpunit --testdox output is very similar to the artisan test output. You can toggle the --testdox via the command palette PHPUnit: Toggle Option --testdox.

In the case of artisan and pest I don't think I mind having specific settings to enable those as candidate test runners instead of the phpunit executable e.g. boolean settings phpunit.pest and phpunit.artisan.

The working directory variable is potentially an issue because paths are already filtered for environment variables the user directory e.g. $HOME/path/... will expand to the user home directory. A relative path like vendor/bin/runner should resolve relative to the working directory so I'm not sure there is a need to explicitly specify it. An absolute path /home/code/project/vendor/bin/runner should resolve without issue too.

The alternative test runner use cases I know of are artisan and pest. At the moment to use pest you can replace the phpunit executable (see #103):

"phpunit.executable": "vendor/bin/pest",
"phpunit.options":
    {
        "colors=never": true
    },

And to use artisan it's a bit hacky (see #102):

    "phpunit.prepend_cmd": ["artisan"],
    "phpunit.executable": "test",
    "phpunit.options":
    {
        "colors=never": true,
    },

We can fix the artisan one to allow the following by allowing the phpunit.executable option to be a list:

    "phpunit.executable": ["artisan", "test"],
    "phpunit.options":
    {
        "colors=never": true,
    },

You can set settings on per-project basis: Menu > Project > Edit Project

{
    "settings": {
        "phpunit.executable": ["artisan", "test"],
        "phpunit.options":
        {
            "colors=never": true,
        },
    }
}
amirHossein5 commented 1 year ago

Yeah that's lighter solution.

gerardroche commented 1 year ago

We can now replace the phpunit.executable with a list so any of the following work:

"phpunit.executable": ["artisan", "test"],
"phpunit.executable": ["vendor/bin/pest"],
"phpunit.executable": "vendor/bin/pest",

I've also added some color output for Pest.