Closed spacedmonkey closed 10 years ago
No, there aren't mainly because there isn't anything to actually test; however, having unit test stubs may not be a bad idea.
I'm moving this to the future state milestone as I'm not sure when the best time to actually implement this may be.
It is not a big deal, but it feels like not as many people as I would like are really unit testing wordpress plugins. If we put the tests in then at least it might get some developer who wouldn't normally do it, to do it. Or get people that have never done it to do it as they never knew how.
If I get anytime at work, I will make a start on it, but I have no idea when that would be.
It is not a big deal, but it feels like not as many people as I would like are really unit testing wordpress plugins
I'm a fan of it - I've even written a series on the topic.
I've been approaching the Boilerplate as a way to help people jumpstart their plugin development, and tests usually aren't deployed to the repository.
To that end, there's still value in that, but it's about educating users on how to do it.
I think this would be something that would help further and improve plugin development, but I'm just not sure on where it'd go - yet.
I read your series @tommcfarlin and that is the reason I thought it would be a good idea to put it in the repo. If you tell plugin creators, look you just have to do some real tests on your plugin before blindly pushing it out, it going to make just everyone's code test. If makes a developer ask the question, what the hell is this tests folder all about then, might push developers down the right course.
:+1: on adding unit tests scaffold/skeleton, whatever. I think having it there would be an encouragement to new devs that "this is what we do" instead of being this nebulous idea "oh hey, you should think about adding unit tests".
Also, including them doesn't mean they must be used.
+1 @jjeaton Exactly
The unit test project mentioned by @nathanielks in #148: https://github.com/johnpbloch/wp-unit-test-project looks pretty good.
I believe WP-CLI can also generate a test scaffold for a plugin.
This also belongs in this discussion I think https://github.com/tierra/wordpress-plugin-tests
This repo contains unit testing skeleton files designed for use in WordPress plugins that utilize WordPress's own unit testing framework and PHPUnit. We've outlined two methods of unit testing your WordPress plugin. First within a local installation of WordPress, and a second method using Travis CI.
I added the unit tests you can generate using WP CLI. They are extremely generic, but that is the point with a boilerplate
Perhaps rather than adding test examples to the boilerplate project, perhaps a second parallel boilerplate-test project could be created which extends from boilerplate.
An example project in which i've seen this done is
https://github.com/jbrinley/wp-forms
https://github.com/jbrinley/wp-forms-test-suite
This test project would provide the basic phpunit setup and a sample class and test class but assume the conventions used by the base boilerplate project.
https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate
https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate-Test
The developer would extract WordPress-Plugin-Boilerplate-Test over the WordPress-Plugin-Boilerplate to enable unit tests for their project.
In the Boilerplate rewrite that we're currently working on, there will be a site, documentation, and hopefully even some advanced code on how to leverage unit tests with the Boilerplate.
They are extremely generic, but that is the point with a boilerplate
@spacedmonkey is on the right track -- this is something that we're tracking and will aim to implement as soon as we can.
This conversation appears to have gone.. quite silent. Is now a good time to ask what the determination was about adding unit testing?
Are there unit test for this plugin available? I am sure that the code has been tested to death, but if there are tests then it might be nice to include them as it is a good jumping off point for creating your own tests.