你可以用JavaScript测试多远? [英] How far can you go with JavaScript testing?

查看:96
本文介绍了你可以用JavaScript测试多远?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点了解TDD和BDD与Ruby / Rails,但我最终需要使用我的JavaScript代码进行某种形式的测试。我使用MooTools作为JS框架,我非常喜欢用代码库组织和模块化代码的能力。但是,有时候,当我向我的应用程序添加新功能时,我发现该功能很容易打破以前的工作方式。

I'm somewhat informed with TDD and BDD with Ruby/Rails, but I will eventually need to use some form of testing with my JavaScript code. I use MooTools as a JS framework and I absolutely love how well I can organize and modularize my code with its codebase. But, sometimes, when I add new features to my application, I find that the functionality can easily break from how it worked before.

在测试JavaScrtpt代码时,测试本身是否缺乏用户交互?它真的只是在JavaScript中测试方法和(模拟)类的细节吗?或者是否有一个UX测试实践,您可以在其中编写单元测试,以查看应用程序的UX行为是否正在执行它应该如何执行?我知道行为是一个广义的术语,但无论如何你可以组织你的JavaScript测试,这样每当你添加新的东西时,你可以休息(有点)保证你的新代码不会破坏任何东西?如何使用任何较大的网络应用程序完成这项工作?

When it comes to testing JavaScrtpt code, does the testing itself fall short of user interaction? Is it really only to test the ins and outs of method and (emulated) classes in JavaScript? Or is there a UX testing practice where you can write unit tests to see if your application's UX behaviour is performing how it should be? I'm aware that "behaviour" is a broad term, but is there anyway that you can organize your JavaScript tests so that whenever you add something new then you can rest (somewhat) assured that your new code won't break anything from before? How is this done with any of the larger web apps out there?

推荐答案

完全没问题,接受并建议使用单位测试框架,例如 JSSp​​ec Jasmine (还有很多其他的)。

It is perfectly fine, accepted and advised to use unit testing frameworks such as JSSpec or Jasmine (there are many others).

然后,你可以做UI单元,功能有时甚至有时甚至使用 Ghostbuster 。这些允许你伪造用户事件和互动。

Then, you may do UI unit, functional and sometimes even integration testing with tools such as Ghostbuster or Selenium. These allow you to fake user events and interaction.

Ghostbuster还很年轻,所以我们对实际用途知之甚少,但Selenium是一个行业标准(我知道它在IBM使用,来源:在IBM工作的老师)。

Ghostbuster is still quite young, so we don't know so much about "actual" uses, but Selenium is an industry standard (I know it is used at IBM, source: teacher working at IBM).

然而,你无法自动测试的是 UX 。 UX代表用户体验,这不是你在软件上测试的东西,只有真正的用户测试。

However, what you can't automatically test is UX. UX stands for User eXperience, and that's not something you test on software, only with real user testing.

这篇关于你可以用JavaScript测试多远?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆