Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dog-fooding qunit #15

Closed
gutzofter opened this issue Mar 23, 2010 · 2 comments
Closed

dog-fooding qunit #15

gutzofter opened this issue Mar 23, 2010 · 2 comments

Comments

@gutzofter
Copy link

I would like for all the private functions to be made public (ex. done(), validTest(), process(), etc.). This would make it an easier chore to start using jquery to unit test the display portion of qunit. Right now the code mixes presentation with testing-logic.

@jzaefferer
Copy link
Member

Could you provide an example of how exposing those would help?

@gutzofter
Copy link
Author

@jzaeffer - I'm sorry! I'm no longer advocating for exposure of the functions. What I'm going to argue for is a plug-in extensibility system.

Case in point:
for (var i = 0; i < config.assertions.length; i++) {
var assertion = config.assertions[i];

    var li = document.createElement("li");
    li.className = assertion.result ? "pass" : "fail";
    li.appendChild(document.createTextNode(assertion.message || "(no message)"));
    ol.appendChild(li);

    if (assertion.result) {
        good++;
    } else {
        bad++;
        config.stats.bad++;
        config.moduleStats.bad++;
    }
}

This code here mixes the test result management with presentation.

In your code base: test storage, test runner, test results, and presentation (even some profiling) are all mixed together.

What I would like to recommend that all these be made plug-ins, with the capabilities to wrap core function.

Here is a unit test that I have for an Ajax request:

should('show kits list when [delete] clicked after clicking on row from kits list', function() {
    var origAjax = $.ajax;
    var testData = {};
    $.ajax = function(data) {
        testData = data;
    };
    $('#kits_tbl tbody tr :first').click();
    $('#delete_edit').click();
    same(testData.data, 'type=remove&kit_number=THX-1138&kit_description=A+Doohickey+used+on+Jaberwockies');

    var response = {};
    response.status = 'success';
    testData.success(response); // process edit

    testData.success(myKitsListContent); // reload content
    $.ajax = origAjax;

    isListVisible();

});

In this test I'm able to wrap the $.ajax function in jquery and utilize my own. This allow me to extend ajax functionality. With this capabilty now I can insert monitoring sensing data/callbacks to ajax.

You can do the same with plug-ins for qunit.

A unit tester only has one concern did my assertions pass or fail. More repsonsibility on the unit tester is too much!

So instead of qunit keeping track of execution time of tests, you can create a plug-in that wraps tests and will keep track of the time of execution.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants