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

[2.x] Add arch test function #9

Merged
merged 4 commits into from
Dec 5, 2023
Merged

[2.x] Add arch test function #9

merged 4 commits into from
Dec 5, 2023

Conversation

lukeraymonddowning
Copy link
Member

Adds a new arch function that is a synonym for test()->group('arch'). This allows users to easily isolate arch tests for inclusion/exclusion when running their test suite.

// Before
it('tests my controllers', function () {
  expect('App\Http\Controllers')->toUseStrictTypes();
});

// After
arch('controllers use strict types', function () {
  expect('App\Http\Controllers')->toUseStrictTypes();
});

If we promote this way of declaring arch tests as the "standard" (in documentation/demos etc), it will allow us to rely on this feature in other tooling (such as mutation testing) to automatically exclude/include architecture tests as required.

It also allows us to add to this function for other cool integrations down the line as we see fit.

One consideration is that currently the PHPStorm plugin does not include support for running functions starting with arch, but as it is open source we could PR that if we want to go ahead with this 👍

src/Autoload.php Outdated Show resolved Hide resolved
Adds a new `arch` function that is a synonym for `test()->group('arch')`. This allows users to easily isolate arch tests for inclusion/exclusion when running their test suite.
olivernybroe added a commit to JetBrains/pest-intellij that referenced this pull request Nov 29, 2023
Add support for an upcoming feature which allows you to write `arch` tests with `arch` function instead of `test` function. 

`arch` function is just a wrapper for `test` where it adds the group `arch` to it also. 
pestphp/pest-plugin-arch#9
@lukeraymonddowning
Copy link
Member Author

I've updated the PR to add support for --arch and --exclude-arch, which is basically shorthand for --group=arch and --exclude-group=arch respectively.

@nunomaduro nunomaduro merged commit 44f98ec into 2.x Dec 5, 2023
0 of 76 checks passed
@nunomaduro nunomaduro deleted the 2.x_arch_function branch December 5, 2023 18:56
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.

2 participants