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.
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:
- Commit to Git.
- Push to Github.
- 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.
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.