[wp-trac] [WordPress Trac] #53363: Test tool and unit test improvements for 5.9

WordPress Trac noreply at wordpress.org
Thu Aug 26 17:45:44 UTC 2021


#53363: Test tool and unit test improvements for 5.9
--------------------------------------+---------------------
 Reporter:  desrosj                   |       Owner:  (none)
     Type:  task (blessed)            |      Status:  new
 Priority:  normal                    |   Milestone:  5.9
Component:  Build/Test Tools          |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+---------------------

Comment (by hellofromTonya):

 @jrf and I discussed [attachment:"53363-09-test-bootstrap-improve-error-
 msg.patch"] per notes she added to the patch attachment. I tested before
 and after with each scenario. Works as expected.

 == Test Report

 Env:
 - WordPress: trunk
 - OS: macOS Big Sur
 - localhost: npm / Docker

 Setup:
 {{{
 npm install
 npm run build:dev
 npm run env:start
 npm run env:install
 composer install
 }}}

 === Scenario 1: `ABSPATH` is `build` but build folder does not exist

 Steps:
 - Change the `ABSPATH` to `build` in the `wp-tests-config.php` file:
 {{{#!php
 define( 'ABSPATH', dirname( __FILE__ ) . '/build/' );
 }}}
 - Run the tests (here running one group of tests but could be any group or
 all tests)
 {{{
 npm run test:php -- --group formatting
 }}}

 Results:
 Before patch:
 {{{
 Error: The /build/ directory is missing! Please run `npm run build` prior
 to running PHPUnit.
 }}}

 After applying patch:
 {{{
 Error: The PHPUnit tests should be run on the /src/ directory, not the
 /build/ directory. Please update the ABSPATH constant in your `wp-tests-
 config.php` file to `dirname( __FILE__ ) . '/src/'` or run `npm run build`
 prior to running PHPUnit.
 }}}

 Works as expected ✅

 === Scenario 2: `ABSPATH` is not `src` or `build` and the folder does not
 exist

 Steps:
 - Change the `ABSPATH` to `doesnotexist` in the `wp-tests-config.php`
 file:
 {{{#!php
 define( 'ABSPATH', dirname( __FILE__ ) . '/doesnotexist/' );
 }}}
 - Run the tests (here running one group of tests but could be any group or
 all tests)
 {{{
 npm run test:php -- --group formatting
 }}}

 Results:
 Before patch:
 {{{
 Error: The /build/ directory is missing! Please run `npm run build` prior
 to running PHPUnit.
 }}}

 After applying patch:
 {{{
 Error: The ABSPATH constant in the `wp-tests-config.php` file is set to a
 non-existent path "/var/www/doesnotexist/". Please verify.
 }}}

 Works as expected ✅

 === Scenario 3: `ABSPATH` is `build` and build folder exists

 Steps:
 - In command-line, run: `npm run build`
 - Change the `ABSPATH` to `build` in the `wp-tests-config.php` file:
 {{{#!php
 define( 'ABSPATH', dirname( __FILE__ ) . '/build/' );
 }}}
 - Run the tests (here running one group of tests but could be any group or
 all tests)
 {{{
 npm run test:php -- --group formatting
 }}}

 Results:
 No errors. Tests run. Works as expected ✅

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53363#comment:71>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list