How to write self-tests for WPLib Box #538
Description
This is a meta-ticket we'll leave open so we can continue adding to these instructions and evolving them. Then at some point we will probably close it and move to our website.
-
Fork github.com/wplib/box-scripts to your own account. Leave the fork open in a tab in your browser.
-
Install a new install of WPLib Box in a new directory using
example.local
as a local hostname. -
Use
vagrant ssh
to enter the box and runbox self-test
to see theself-test menu
. Then runbox self-test run
which may currently (on purpose) generate a few errors. -
In a new terminal window
vagrant ssh
in your project and then runbox sync notstop
. This will create a/box
directory in theexample.local
project. -
Change into the
/box
directory inside the box (after runningvagrant ssh
) and change thegit remote
to the URL of your fork from step Content for default web page #1 (that is why we asked you to leave the browser open, so you can go back and copy the URL.) -
In your editor or IDE with the
example.local
project open, find the files in/box/cli/tests
and notice the files in this directory all have a.test
. These are theself-test
tests. -
Study these
.*.test
files to learn how to write tests, and also look at the test framework at/box/cli/tests/includes/framework
. You can also see this file online *here. -
Review the high-level test tickets here.
(We intend to add specific test for each
box
subcommand and each subcommand of WP ClI, Composer and any of the other tools or components we are including in the box. For example, a ticket to write a test forwp plugin list
would be appropriate. Please don't want on us to do so; feel free to start creating these tickets yourself.)-
One of the things we need to figure out if the best way to setup data so tests can run deterministically, and also to "mock" our tests. If you have any ideas to contribute here they will be greatly appreciated.
-
We also need to add to our
test<Criteria>()
andeval<Criteria>
convenience testing functions, which can be found in/box/cli/tests/includes/assertions
.
-
-
If you have questions along the way, or want to brainstorm how best to test anything please reach out on [http://launchpass.com/wplib](our Slack) in the #box channel to discuss.
-
When you have tests written and ready to contribute, please submit a pull request on GitHub to our branch
0.17.2
.
Any other questions? See you in our Slack.