Is there a difference between Travis CI running my PHPUnit tests and me using the WP-CLI to generate unit test files and running phpunit locally? I'm wondering if the duplicate effort is necessary or unnecessary.

  • Please look up what a CI service like Travis, Circle or Codeship does. In short, no there is no difference
    – kaiser
    Jan 24 '16 at 12:37

Travis is a hosted continuous integration service. Travis takes the files you've committed to your Github repo, and runs PHPUnit against them.

Notably different than running phpunit in your local environment is that running tests on Travis requires at least three steps:

  1. Commit to Git.
  2. Push to Github.
  3. Wait for Travis to create and run a build.

In the long term, it will be much faster for you to first run your tests locally before you commit, to reduce the amount of time you have to wait to see if your tests fail.

  • Aside from the wait time, are there any more advantages of running phpunit locally? Jan 23 '16 at 8:52
  • Sure — your commit log won't be full of debugging commits where you're only pushing code to Travis to see if it passes the tests. Jan 24 '16 at 14:19
  • I suppose there's also the advantage of having a clean commit history. If a build fails locally, then you can fix before committing Jan 24 '16 at 18:11

Travis CI is great for alerting you to problems, like errors or failing tests. However, it isn't very useful for debugging. If your project is small and the code is simple, you probably don't need to run the tests locally. But for most projects with a fair amount of code, finding the root cause of failing tests often takes a great deal of debugging. Being able to run the tests and debug the problem on your local machine (possibly using xdebug or the like) is extremely helpful.

Also, as Daniel Bachhuber pointed out, having the tests installed locally allows you to run them without having to send your code off to Travis and wait for the build to run. Running local tests is much quicker, and allows you to test your code as you go along, without having to commit it before finding out if it works.

For these reasons I think you will find that you'll want to install the tests locally.


Not the answer you're looking for? Browse other questions tagged or ask your own question.