Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Regular Coder
    Join Date
    Jan 2013
    Location
    Germany
    Posts
    578
    Thanks
    4
    Thanked 77 Times in 77 Posts
    My question would mostly be: Why do you want to unit-test Javascript in Java? Unless you have a reason to, I'd simply not do it.

    There are a lot of great Javascript testing frameworks out there (Jasmine, QUnit, Mocha, …) and since Javascript can be browser-sensitive, they can simply be run in different browsers. They also work for node.js applications.

    And I'd rather go with an established framework than developing my own here. If you want to write a testing framework on your own just for the fun of it, though, then it's just up to what you feel like. But since I don't really see the point in doing this in Java – I write my Java tests in Java, my Javascript tests in Javascript, … –, I'd recommend going with Javascript itself here.

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,186
    Thanks
    10
    Thanked 569 Times in 550 Posts
    i don't think java would be much use. sure you can test JS logic with it, but it would be hard/impossible to test actual current JS/DOM interaction. the browsers are developing so fast that it's hard to keep up an environment like a browser outside a browser. Artificial environments and even headless browsers only go so far in emulating a production browser. Since most JS bugs result from DOM/Host incompatibility/conflicts, an in-browser test is the only way to catch most bugs consistently.

    i often roll up integrated unit tests with my apps, but i never use a framework; it's so easy to pound out a custom 5-10 line app-integrated assert() when i need one that there's i've found no reason to include outside code.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5

  • #4
    Regular Coder
    Join Date
    Jan 2013
    Location
    Germany
    Posts
    578
    Thanks
    4
    Thanked 77 Times in 77 Posts
    I used to write asserts for my project myself. In my latest Javascript project I'm using Jasmine, and I gotta say I love it. It certainly is a lot more comfortable than writing my own assertions, even though I'm not even using the more complicated functionality.


  •  

    Posting Permissions

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