Results 1 to 3 of 3

Thread: Project Management, Testing and basic Javascript questions

  1. #1
    Join Date
    Nov 2005
    Posts
    477
    Rep Power
    10

    Default Project Management, Testing and basic Javascript questions

    I have been working on a time management system that is modeled on tasks (things to do, and how long they took to do) and contexts (tasks depend on other tasks, and tasks should be recorded for billing purposes).

    As part of this, I wrote a real quick and dirty unit testing (and hopefully functional testing as well) zimlet that I can use to plan out code, and to test my code base.



    Right now to run each test, I have a lot of code that reads:
    Code:
    TestController.startTest(this, this.taskCreate);
    Which obviously, I would like to automate. Is there any way to programmaticly reflect/introspect in javascript to look for methods that match a particular name (starts with test, one format param?)

  2. #2
    Join Date
    Sep 2006
    Posts
    252
    Rep Power
    9

    Default

    I don't understand you much but a for...in loop through the object class may work.

    Code:
    var res = [];
    for(var i in this){
    if(typeof(this[i]) == "function" && !i.indexOf("test")){
    res.push(i);
    }
    }
    alert(res.join("\n"));
    Yeeha! Feels nice to post code

    Fernando

  3. #3
    Join Date
    Nov 2005
    Posts
    477
    Rep Power
    10

    Default

    Quote Originally Posted by __proto__ View Post
    I don't understand you much but a for...in loop through the object class may work.

    Code:
    var res = [];
    for(var i in this){
    if(typeof(this[i]) == "function" && !i.indexOf("test")){
    res.push(i);
    }
    }
    alert(res.join("\n"));
    Yeeha! Feels nice to post code

    Fernando
    That works like a champ! Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •