Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have started using BDD for a wordpress plugin i'm working on and i'm rewriting the js codebase to do tests. I've encountered a few problems but i'm going steady now, i was wondering if i had the right approach, because i'm writing test that should pass in a normal browser environment and not inside wordpress.
I choose to do this because i want my plugin to be totally indipendent from the wordpress environment, i'm using requirejs in a way that i don't expose any globals and i'm loading my version of jQuery that doesn't override the one that ships with Wordpress. In this way my plugin would work the same on every wordpress version and my code would not break if they cheange the jQuery version or someone use my plugin on an old wordpress version. I wonder if this is the right approach or if i should always test inside the environment i'm working in. Since wordpress implies some globals i had to write some function purely for testing purpose, like

"get_ajax_url": function() {
    if( typeof window.ajaxurl === "undefined" ) {
        return "http://localhost/wordpress/wp-admin/admin-ajax.php";
    } else {
        return window.ajaxurl;

but apart from that i got everything working right. What do you think?

share|improve this question
up vote 1 down vote accepted

I think you're on the right track, including your methodology.

As an enhancement, you could create additional tests that run within the wordpress application environment. You might want to do this if you needed to generate additional diagnostic information when a failure occurs. Another situation is if you needed advanced triggers to be fired that can only occur within the application / plugin and aren't triggered by user interaction.

At a more abstract level, what you're doing is creating test sets based upon how the user will interact with your application / plugin. For the beginning and intermediate stages of test design, this is an excellent place to start. It presents the most value / reward for your effort and it gives you a degree of assurance that your users will get what you expected.

Guaranteeing the UI experience will go a long way towards keeping your user base happy.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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