Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Improving WordPress Development Quality

Improving WordPress Development Quality

Topic Description:
--------------------------
1. Understand Quality in general and change mindset towards "Quality is everyone's responsibility."
2. As a developer, aspects where I can contribute towards the improvement of quality of my own work. Like unit testing, test scripts, code standards etc...
3. A basic introduction to different tools, methods like BDD, TDD
5. How to implement in our code and make our WP better
6. Some examples
7. Conclusion

If you are into UI, development or QA. This will be the best session for you if you are thinking to step up your level of Quality in WordPress.

Speaker:
==============
Anish Shah

Ahmedabad WordPress Meetup

September 22, 2019
Tweet

More Decks by Ahmedabad WordPress Meetup

Other Decks in Programming

Transcript

  1. Developers + QA • QA = Quality Assurance • How

    many Beginners dev? How many QA?
  2. Understand Quality • What is Quality? • Quality = Conformance

    to requirements • Mindset: Quality is everyone’s responsibility
  3. Code Level Improvements • Following WP standards ◦ https://github.com/WordPress/WordPress-Coding-Standards •

    Avoid - No maintenance ◦ https://developer.wordpress.org/plugins/wordpress-org/take-over-an-existing-plugin • Malleable code (extensible?) • Stick to the DRY & KISS principle. ◦ Avoid duplicated code using code in template part files. • Keep functionality out of your themes – use a plugin instead. • Secure your code ◦ https://wordpress.org/support/article/hardening-wordpress
  4. Types of testing • Unit testing ◦ the first step

    to guarantee your code works. ◦ a function, usually—works as intended? ◦ A unit test will simply check that, given a certain input, we get the expected output. • Integration testing ◦ Different pieces of our plugin come together, they serve a greater purpose and solve a bigger problem. ◦ To make sure that all the different components work properly altogether • Acceptance Tests ◦ Write tests that simulate the interaction of a user with their browser.
  5. TDD • Workflow # previous ◦ you write some code,

    ◦ you create the tests that verify it, ◦ you execute the tests and make sure that everything works as expected. • Workflow # TDD ◦ first, you write the test for a new functionality, ◦ you verify the test fails (and it will fail, because you haven’t write any code for that new functionality), ◦ you write some new code to solve the problem at hand, ◦ you execute the test and make sure that, after your new code is over, it passes.
  6. TDD Example <?php class WP_Meta_Verify { public function __construct() {

    add_action('wp_head', \[$this, 'header_code']); } public function header_code() { $google_code = get_option('wpmv_google_code'); echo $this->google_site_verification($google_code); } public function google_site_verification($code) { return "<meta name=\"google-site-verification\" content=\"$code\">"; } } new WP_Meta_Verify();
  7. TDD Example cont... public function test_google_site_verification() { $meta_tag = $this->class_instance->google_site_verification('B6wFaCRbzWE42SyxSvKU

    OyyPxZfJCb5g'); $expected = '<meta name="google-site-verification" content="B6wFaCRbzWE42SyxSvKUOyyPxZfJCb5g">'; $this->assertEquals($expected, $meta_tag); } // https://github.com/anish274/wp-meta-verify
  8. TDD Benefits • Modular design ◦ Cleaner & clearer code

    ◦ It is isolated and easily traceable ◦ Faster development and faster changes • Detects my webapp is affected by the latest change or not • Tests become the documentations