JavaScript 测试你能走多远?

发布于 2024-12-15 18:31:18 字数 400 浏览 0 评论 0 原文

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

在测试 JavaScrtpt 代码时,测试本身是否缺乏用户交互?它真的只是为了测试 JavaScript 中方法和(模拟)类的来龙去脉吗?或者是否有用户体验测试实践,您可以编写单元测试来查看应用程序的用户体验行为是否按应有的方式执行?我知道“行为”是一个广泛的术语,但是无论如何,您是否可以组织您的 JavaScript 测试,以便每当您添加新内容时,您就可以(在某种程度上)放心,您的新代码不会破坏以前的任何内容?对于任何较大的网络应用程序来说,这是如何完成的?

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.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

百合的盛世恋 2024-12-22 18:31:18

完全可以,已接受并建议使用单元测试框架,例如 JSSpecJasmine (还有很多其他的)。

然后,您可以使用 Ghostbuster。这些允许您伪造用户事件和交互。

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

然而,您无法自动测试的是UX。 UX 代表用户体验,这不是您在软件上测试的东西,只能通过真实的用户测试来测试。

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

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 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).

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文