How do I decide what testing framework to use?

The situation is this.

I’m a junior developer for a small government IT project. We don’t have anything of continuous integration or a automated testing framework. But the idea is to be developing this kind of thing/improving our developing environment.

The product is a data processing algorithm that then displays information to the end user via a webapp.

So coming up is a bunch of work modifying the webapp javascript. As such we want to implement a unit testing for the javascript.

I’ve looked at this stack overflow question which outlines several different unit testing frameworks for javascript.

The question is – how do I decide between which framework to start using?

  • What is a list of criteria for choosing a testing framework?
  • Is it practical to try them all out?
  • Spend a lot of time reading forums/etc about how they’re used?

What is a list of criteria for choosing a testing framework?

1) Syntax

As you investigate different test frameworks you will notice that syntax is a differentiating factor across all of them. This is really going to depend on what makes you feel comfortable.

For example, qUnit is more of a declarative test framework. Its API consists of functions called test, equals, strictEqual, deepEqual, etc.

Another test framework, mocha, is more like rspec in that it reads in a more sentence like structure. Its API consists of functions called describe, it, assert.equal, etc.

My personal preference is a qunit like structure.

2) Features – Stubs, Spies, Fake server, Fake clock, etc

When you start testing in Javascript you will quickly find yourself in situations where you need your test framework to help you test certain use cases. For example:

Spies – This will help you detect whether your code called a function when it should have

Stubs – Very similar to a spy except it contains predefined behavior (Example: When the stub is called, return foo)

Fake Server – If your code issues AJAX calls and you want to fake the response of the AJAX call, a Fake Server will help you more easily test.

Fake Clock – If your code reacts differently based on the date or time, then a fake clock will help you control exactly what time it is while your test runs.

My recommendation for a Javascript Framework that supports all the features above is Sinon.JS. Because I like a qunit like syntax and framework, I use qunit AND Sinon.JS. qunit handles my assertions and runs my tests. Sinon.JS gives me the ability to stub, spy, run a fake server, and fake the clock.

3) Community Support

Is your test framework supported by the community? For example, grunt (a build environment tool) supports running qunit in a headless PhantomJS server: https://github.com/gruntjs/grunt-contrib-qunit . This makes it easy to write tests and have them be automatically run everytime I save the test file.

Is it practical to try them all out?
No it is not practical. Instead investigate each framework’s website and pick one that you feel comfortable with and one that will also support you while your write tests.

Spend a lot of time reading forums/etc about how they’re used?
Grab a book on the framework you choose and skim through it as you need it.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật