简体   繁体   English

Javascript 与 CruiseControl、nUnit、nAnt 和 ASP.net MVC 集成的自动化单元测试

[英]Automated Unit testing for Javascript integrated with CruiseControl, nUnit, nAnt and ASP.net MVC

I work for a team of ASP.net MVC and they are using Cruisecontrol, nUnit and nAnt for the automated testing and build.我为 ASP.net MVC 团队工作,他们使用 Cruisecontrol、nUnit 和 nAnt 进行自动化测试和构建。 I am new to the group and i handle the Javascript layer and i am looking for ways to incorporate my work with my teams workflow.我是小组的新手,我处理 Javascript 层,我正在寻找将我的工作与我的团队工作流程结合起来的方法。

Are there any possoble way to do this?有没有办法做到这一点?

Thanks谢谢

A few thoughts:一些想法:

  • There is JSUnit, a unit test framework for JavaScript.有 JSUnit,一个用于 JavaScript 的单元测试框架。 I used it a 2 years ago and it was pretty good.我2年前用过,效果还不错。 Something better may be out there now.现在可能会有更好的东西。
  • I assume they're using source code control of some form, and that Cruise Control monitors the repository.我假设他们正在使用某种形式的源代码控制,并且 Cruise Control 监视存储库。 If so, then just make sure your JavaScript is kept in the same repo, so it will trigger builds, automatic kickoff of unit tests, etc.如果是这样,那么只需确保您的 JavaScript 保存在同一个仓库中,这样它就会触发构建、单元测试的自动启动等。
  • If you have portions of your JavaScript layer that can only be tested in a browser, think about using Selenium or a similar tool to create a kind of automated tests that drive the browser through various scenarios.如果您的 JavaScript 层的某些部分只能在浏览器中进行测试,请考虑使用 Selenium 或类似工具来创建一种自动化测试,以驱动浏览器通过各种场景。 I'm sure there is a way to kick these off from Cruise Control.我确信有一种方法可以从巡航控制系统中启动这些。

Just a couple of days ago, John Resig announced a JavaScript unit test automator he's working on called Test Swarm .就在几天前,John Resig 宣布了他正在开发的名为Test Swarm的 JavaScript 单元测试自动机。 It's just now going into alpha, but it might be worth watching.它刚刚进入 alpha 阶段,但可能值得一看。

I've found JSUnit to be a pretty good unit testing tool for javascript.我发现 JSUnit 是 javascript 的一个非常好的单元测试工具。

You might also consider using javascript lint (link below).您也可以考虑使用 javascript lint(下面的链接)。 It's a static code analyzer (not a unit testing tool) and I've had good experiences with it in the past.这是一个 static 代码分析器(不是单元测试工具),我过去有过很好的经验。 It's not as thorough as some of the complied language lint tools, but it can save you from making some truly evil mistakes in javascript.它不如某些已编译的语言 lint 工具那么彻底,但它可以使您免于在 javascript 中犯一些真正邪恶的错误。 You can run it from the web page or the command line, so it should wire into a build process pretty easily.您可以从 web 页面或命令行运行它,因此它应该很容易连接到构建过程。

http://www.javascriptlint.com/index.htm http://www.javascriptlint.com/index.htm

As @Charlie mentions, JsUnit is a good choice for automated unit testing, via JsUnit Server .正如@Charlie 所提到的,JsUnit 是通过JsUnit Server进行自动化单元测试的不错选择。

QUnit is a new unit testrunner, is highly customizable, I've been playing with it and you can integrate and check the test results through browser automation tools like Selenium . QUnit是一个新的单元测试运行器,高度可定制,我一直在玩它,您可以通过Selenium浏览器自动化工具集成和检查测试结果。

That's pretty much what we have at the moment, but a very promising project is emerging right now, TestSwarm by Mr. John Resig, check this blog post for more information (and sign up for the alpha release:):这几乎是我们目前所拥有的,但是现在正在出现一个非常有前途的项目,John Resig 先生的TestSwarm ,查看此博客文章以获取更多信息(并注册 alpha 版本:):

Looks really interesting:看起来真的很有趣:


(source: ejohn.org ) (来源: ejohn.org

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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