wplib / wplib-box

The Best Local Dev Server for WordPress Developers

Home Page:https://wplib.github.io/box-docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to write self-tests for WPLib Box

mikeschinkel opened this issue · comments

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.

  1. Fork github.com/wplib/box-scripts to your own account. Leave the fork open in a tab in your browser.

  2. Install a new install of WPLib Box in a new directory using example.local as a local hostname.

  3. Use vagrant ssh to enter the box and run box self-test to see the self-test menu. Then run box self-test run which may currently (on purpose) generate a few errors.

  4. In a new terminal window vagrant ssh in your project and then run box sync notstop. This will create a /box directory in the example.local project.

  5. Change into the /box directory inside the box (after running vagrant ssh) and change the git remote to the URL of your fork from step #1 (that is why we asked you to leave the browser open, so you can go back and copy the URL.)

  6. 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 the self-test tests.

  7. 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.

  8. 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 for wp plugin list would be appropriate. Please don't want on us to do so; feel free to start creating these tickets yourself.)

    1. 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.

    2. We also need to add to our test<Criteria>() and eval<Criteria> convenience testing functions, which can be found in /box/cli/tests/includes/assertions.

  9. 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.

  10. 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.