最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How do I unit test JavaScript using nUnit? - Stack Overflow

programmeradmin0浏览0评论

I would like to run unit tests of my JavaScript code in Cruise Control. We currently use nUnit, and I see that nUnit has a javascript library. How do I write unit (not UI) tests in JavaScript using nUnit?

I would like to run unit tests of my JavaScript code in Cruise Control. We currently use nUnit, and I see that nUnit has a javascript library. How do I write unit (not UI) tests in JavaScript using nUnit?

Share Improve this question edited Apr 27, 2015 at 20:57 George Stocker 57.9k29 gold badges181 silver badges238 bronze badges asked Jul 12, 2010 at 11:30 dehadeha 81511 silver badges30 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

The best way to automate JS tests and include them in continuous integration process is to use JSTestDriver. It is very fast, can test your scripts in all kinds of browsers, can be easily integrated in IDE (How To ntegrate JsTestDriver in Visual Studio), and what is more important - this is simple sole application, which can be easily be executed from nant script.

The example of solution with JsTestDriver tests is here.

You can do this with JSUnit. Their JSUnit Server allows you to run scriptable JavaScript unit tests within a Java virtual machine (JVM).

You can use Rhino, which is a Javascript runtime written in Java (IIRC, the mand-line is something like java -jar Rhino.jar script.js). This is especially useful if your tests don't require a browser.

Don't forget to analyze your JS code with JSLint !

发布评论

评论列表(0)

  1. 暂无评论