简体   繁体   中英

JavaScript unit testing tools for Visual Studio / Build Server - any consensus yet?

Here's the situation:

  • We're a Microsoft shop using Visual Studio / TFS etc.
  • We have a build server that nightly performs builds for us and runs various tests to ensure nothing has been broken during the day
  • We're now doing more and more JavaScript and this is likely to continue.

None of our JavaScript is currently tested because as I've looked around I've found the JavaScript testing world is in a state of flux. There are lots of offerings which I've read about and I'm not sure which path to take. I found this question quite helpful in terms of just raw info:

JavaScript unit test tools for TDD

Ideally I'd like to use something which integrates nicely into Visual Studio and our TFS build server. Most of the JavaScript testing options do not seem to support this.

I found this article: (but I'm not too keen on using jscript for testing)

http://stephenwalther.com/blog/archive/2010/12/20/integrating-javascript-unit-tests-with-visual-studio.aspx

And I found this - which looks quite promising:

http://chutzpah.codeplex.com/

So what I'm wondering is, is there any consensus yet? Are people adopting one tool over another, is any approach gaining critical mass yet? I'm keen to make use of something which is clearly working for a lot of people already.

Is it worthwhile me sticking it out for a JavaScript testing framework that plays nice with Visual Studio / TFS or should I look to use one of the non Microsoft friendly offerings instead?

All insights appreciated!

I wouldn't got that far and state that I'm moving away from developing in MS environment. I think Visual Studio is a great tool. Working a little with Eclipse & XCode, for PhoneGap development even gave me another perspective as to how Visual Studio really rocks.

Regarding JavaScript, there are many enhancements in Visual Studio 2012, but integral solution for Unit Testing is not yet part of it.

After being involved in some JavaScript heavy projects, also felt the need for Unit Testing, so started with In-Browser tests with QUnit and Sinon.JS.

I went out there to find the right stack to meet my expectations:

  • Seamless integration with Visual Studio. So we can run tests without leaving the IDE.

  • Headless testing. Against multiple browsers at the same time if possible.

  • Support for AMD (Asynchronous Module Definition) / Require.JS.

  • Support for Async Tests.

  • Documented libraries & Tools.

  • Free Tools are preferred.

Eventually find my perfect combination for Headless testing from inside the IDE with JS-Test-Driver.

I've written a 3 parts series on my blog:

  • Part I - Expectations & the selected Stack

  • Part II - Setting up the environment for Headless tests

  • Part III - Testing AMD/Require.JS Modules

You can find the last part here, with links to first 2 posts:

http://www.upstruct.net/2013/02/javascript-unit-testing-in-visual-part-3.html

Been using this combination in several projects, and got a very good feedback from the teams so far.

Let me know if it suits you...

I've been looking around for the same answer but am now wondering if I should move away from developing in an MS environment altogether. As more and more of what I do is on the client side, Visual Studio seems less relevant. Funnily enough though, since I've been playing with Eclipse I've had the same problem - lack of JS testing plugins! So I'm not sure there's a consensus outside of MS development. I think part of this is a reluctance of seasoned developers of C# / Java to use JS but rather they want to use a strongly typed language which compiles (using tools like GWT and Script Sharp). The result is confusion about what comprises best practice. But since the tools for JS seem to be improving I'm somewhat reluctantly coming to the conclusion that JS should be the first point for coding rather than adding another layer of abstraction. Thus I'm resigned to using their available tools - QUnit for the moment is my choise.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM