SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Sep 2013
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unit testing tool for Javascript applications

    Hello..
    Could someone please tell me whether I can use Java Language to develop an automatic unit testing tool for Javascript functions or whether I should go for Javascript itself?
    And may I please know all difficulties I might face if I would be using Java instead of Javascript itself to develop the testing tool.

    Many many thanks,
    Dani_zone

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,433
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)
    Hi Dani_zone, welcome to the forums

    Interesting thought.

    Most Unit tests I've seen are written in the language they're testing. eg.
    Ruby in Ruby
    PHP in PHP
    Python in Python
    etc.

    But as Javascript is client-side it might actually be better and/or easier to write the Unit tests in another language.
    Though I think you'l at least need to use Javascript to do the Submits.and function calls.

  3. #3
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,576
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    There are more and more js testing frameworks coming out. I would check out http://www.manning.com/resig/ for some ideas as to how to approach it from the guy who created jquery. I haven't had enough seat time with any of the frameworks to know which one to use.

    What I have had some seat time with is using selenium to build integration tests -- it can fire up browsers and hit your QA sites and run the full-blown site with scripts there so you can get end to end tests. You can hook into that using your server-side language of choice through a few means, check out http://docs.seleniumhq.org/ for details. But that certainly isn't a unit test though half the time when people ask for unit tests they are really asking for automated testing frameworks.

  4. #4
    SitePoint Mentor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,256
    Mentioned
    32 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by wwb_99 View Post
    There are more and more js testing frameworks coming out. I would check out http://www.manning.com/resig/ for some ideas as to how to approach it from the guy who created jquery. I haven't had enough seat time with any of the frameworks to know which one to use.
    Resig developed a unit testing framework for JS which is now called QUnit. Jasmine seems to be very popular in the JS community at the moment - it's more for BDD than unit testing, so it really depends what you prefer.

  5. #5
    SitePoint Member
    Join Date
    Sep 2013
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    Hi Dani_zone, welcome to the forums

    Interesting thought.

    Most Unit tests I've seen are written in the language they're testing. eg.
    Ruby in Ruby
    PHP in PHP
    Python in Python
    etc.

    But as Javascript is client-side it might actually be better and/or easier to write the Unit tests in another language.
    Though I think you'l at least need to use Javascript to do the Submits.and function calls.
    Hi Mittineague.. could you please elaborate a little more in last part where you mentioned that I will be using
    Javascript to do the submits.
    so you mean Java would be fine if I would be using this language to develop the tool? Any problem I would be facing in future according to you?

  6. #6
    SitePoint Wizard
    Join Date
    Apr 2007
    Posts
    1,381
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I have yet to see successful JavaScript Unit test. I wasn't in the team but it failed miserably due to how sensitive the test can fail w/ minor changes. It would take more time fixing the tests then implementing the business logic. I did hear a way that you can build Unit test based on screen capture. This would be a lot easier to test. For example, if user logs in then it must match this screen shot. If an error occurs during login, then it must match this screen shot. I forget the name but I'm sure google will help.

    If you truly want to test using Java then I'd suggest GWT. I don't think you need to use GWT in providing the UI javascript but use it to create whatever JavaScript you need. The beauty of it is that the source is written in Java, which means it's very easily testable using JUnit.

  7. #7
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,433
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)
    I may have been wrong in my assumptions. I was unaware of any application being able to automate browsers. Going by the reply made by wwb_99
    selenium to build integration tests -- it can fire up browsers and hit your QA sites and run the full-blown site with scripts there
    If it can work with
    http://docs.seleniumhq.org/docs/
    Java, C#, Python, Ruby, PHP, Perl, Javascript
    it sounds very promising.

  8. #8
    SitePoint Member
    Join Date
    Sep 2013
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So Mittineague, you mean that I can use Java for developing the unit testing tool for Javascript functions?
    but I wanted to know why all the existing tools are developped in JavaScript itself and that no one has developed it another language?
    Any specific reason for this?
    And if I am using Java for the tool how to start with everything?

  9. #9
    Non-Member
    Join Date
    Feb 2012
    Posts
    892
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)
    Why use JS for JS testing? Simply because unit testing in a language should not require you to learn another language.

    There are a number of unit testing tools for JS written in JS, the few mentioned above and YUI Test and Mocha being note worthy.

    But if you were following recent JS trends, lately there's some news going on about BrowserSworm: http://www.browserswarm.com

  10. #10
    SitePoint Member
    Join Date
    Sep 2013
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks lots for providing the above link.


Bookmarks

Posting Permissions

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