gjstest单元测试框架
gjstest(Google JS Test)是在 V8 引擎上快速运行 javascript 单元测试框架的工具,且不需要用户启动完整的浏览器。当然,假如你在 V8 上面测试的时候没有浏览器也没有 DOM 的话,你可以使用本工具来完成测试。
特征如下:
能够极快的启动测试和执行测试,且不需要运行浏览器
输出可读的测试结果,测试失败也可读、明了
一个基于浏览器的测试运行工具能够随 JS 的变化而变化
风格和语义都类似 C++风格
内置模拟框架,所以只需要极少的代码即可完成测试
代码示例:
function UserInfoTest() { // Each test function gets its own instance of UserInfoTest, so tests can // use instance variables to store state that doesn't affect other tests. // There's no need to write a tearDown method, unless you modify global // state. // // Create an instance of the class under test here, giving it a mock // function that we also keep a reference to below. this.getInfoFromDb_ = createMockFunction(); this.userInfo_ = new UserInfo(this.getInfoFromDb_); } registerTestSuite(UserInfoTest); addTest(UserInfoTest, function formatsUSPhoneNumber() { // Expect a call to the database function with the argument 0xdeadbeef. When // the call is received, return the supplied string. expectCall(this.getInfoFromDb_)(0xdeadbeef) .willOnce(returnWith('phone_number: "650 253 0000"')); // Make sure that our class returns correctly formatted output. expectEq('(650) 253-0000', this.userInfo_.getPhoneForId(0xdeadbeef)); }); addTest(UserInfoTest, function returnsLastNameFirst() { expectCall(this.getInfoFromDb_)(0xdeadbeef) .willOnce(returnWith('given_name: "John" family_name: "Doe"')); // Make sure that our class puts the last name first. expectEq('Doe, John', this.userInfo_.getNameForId(0xdeadbeef)); });
评论
QUnitjQuery 单元测试框架
QUnit是一个功能强大、易于使用的JavaScript单元测试框架。它被jQuery项目用于测试代码和插件,它能够测试任何通用的JavaScript代码(甚至能够在服务器端测试JavaScript代
QUnitjQuery 单元测试框架
0
xUnit.net.NET单元测试框架
NUnit 的创造者JimNewkirk公布了一个新的单元测试框架,叫做xUnit.net。这个以NUnit接班人自许的新框架打算消除NUnit的错误和缺点,并打算在框架中加入一些最佳实践和扩展能力。
xUnit.net.NET单元测试框架
0
PyUnitPython 单元测试框架
PyUnit是Python版JUnit,一款Python单元测试框架。PyUnit可以在Python1.5.2及更高版本上运行。作者已经在Linux(Redhat6.0和6.1以及DebianPota
PyUnitPython 单元测试框架
0
zMMIXMMIX单元测试框架
zMMIX是一个MMIX单元测试框架:用于测试TAOCP里面的MMIX程序特点:简单的case编写。用户不再需要自己编写:Main代码去运行、查看一段MMIX程序的运行结果。测试数据驱动。用户主要关心
zMMIXMMIX单元测试框架
0
JUnitJava单元测试框架
JUnit是一个Java语言的单元测试框架。它由KentBeck和ErichGamma建立,逐渐成为源于KentBeck的sUnit的xUnit家族中为最成功的一个。JUnit有它自己的JUnit扩展
JUnitJava单元测试框架
0
NodeUnitNode.js 单元测试框架
NodeUnit是Node.js的单元测试框架,基于assert模块为node.js和浏览器提供了简单的异步单元测试。特征使用简单只需从模块中导出测试与node.js一起使用并在浏览器中帮助您在测试异
NodeUnitNode.js 单元测试框架
0