Tag: 压力testing

Nodejstesting。 如何避免竞赛条件?

我目前正在编写一个nodejs的游戏引擎。 我的游戏有几个州。 我们称之为StateA,StateB,StateC。 序列stream程是StateA => StateB => StateC。 我想在每个状态结束时testing我的引擎状态。 我目前有这样的结构: function attachEventListeners = function(instance) { instance.on('START_STATE_A', stateA); instance.on('START_STATE_B', stateB); instance.on('START_STATE_C', stateC); } var stateACallBack = function() {}; var stateBCallBack = function() {}; var stateCCallBack = function() {}; function stateA() { // Do something… stateACallBack(); setTimeout(function() { this.emit('START_STATE_B'); }, 3000) } function stateB() { // Do […]

如何用process.nextTick进行testing

我正在使用摩卡来testing一些Node.js代码,并希望使用process.nextTick()来调用方法的callback。 代码 @getNouns: (callback) -> @_wordnik.randomWords( includePartOfSpeech: 'noun', (e, result) -> throw new Error('Wordnik Failed') if e process.nextTick -> callback(result) ) 考试 it 'should call a callback with the response', (done) -> sinon.stub(Word._wordnik, 'randomWords').yields(null, [ {id: 1234, word: "hello"}, {id: 2345, word: "foo"}, {id: 3456, word: "goodbye"} ] ) spy = sinon.spy() Word.getNouns (result) -> […]

我能做些什么来改善我的testing?

最近我试图让我的头在与Mongoose作为MongoDB包装的节点JS的testing驱动开发。 我的问题是我做对了。 我在testing正确的东西,我应该做更多的testing,涵盖空值等。你认为我可以改进的东西是什么? 随意批评尽可能多的,如你所愿。 testing: var assert = require("assert"), mongoose = require("mongoose"), sugar = require("sugar"), Factory = require("factory-lady"), Timekeeper = require("timekeeper"), Link = require("./../app/models/link"); mongoose.connect("mongodb://localhost/link_test"); Factory.define("link", Link, { createdAt: new Date("2012-04-04"), title: "Example", updatedAt: new Date("2012-04-05"), url: "http://www.example.com" }); describe("Link", function() { describe("validation for", function() { ["url", "title"].forEach(function(property) { it("must have a " + property, […]

Node.js + socket.io确定每个实例的最大客户端数量

我被要求粗略计算一个大的EC2实例(16Gb Ram,4 Core Xeon)上的单个socket.io实例句柄的数量。 我更新了简单的socket.io基准的样本。 Serever: var io = require('socket.io').listen(80); var exec = require('child_process').exec; io.configure(function() { io.set('log level', 1); var transport = process.argv.length >= 2 ? process.argv[2] : null; if (transport) { io.set('transports', [transport]); } }); var payload = "Payload: Payload line item " + "Payload: Payload line item " + "Payload: Payload line item […]

基准Nodejs项目

我正在尝试构build一个nodejs Web应用程序。 当我添加更多的代码时,最好有一种方法来testing这种改变对性能的影响,如果可能的话,我的应用程序花费最多的时间。 目前我正在使用mocha作为我的testing框架,我可以从中得到一些基准testing信息,因为它会报告每个testing需要多less时间。 不过,我最终偶尔编辑testing,使我以前的所有基准无效。 我想知道是否有人有任何build议nodejs模块或方法如何做到这一点。

用mochatestingnode.js – Newbie

我已经开始在我的JS项目中实现TDD。 我为此目的实施了摩卡。 由于这些是我所做的第一步: 安装了node.js 为我的项目在全球和本地安装了摩卡。 写了package.json设置依赖关系。 写了makefile。 写了.gitignore以避免上传node_modules文件夹。 文件夹结构 项目 – js —- filetotest.js – test —- test.js 我想要做的就是运行命令make test,以便在testingfiletotest.js文件的test.js中运行testing。 我读了关于使用导出的node.js方法。 但有没有办法将文件包含在testing套件中? 我被困在这里,我认为我的怀疑更多是关于概念而不是科技的东西。 会很感激你的帮助。 澄清一下我想做什么: https : //nicolas.perriault.net/code/2013/testing-frontend-javascript-code-using-mocha-chai-and-sinon/ 我想通过命令行得到类似的结果。 非常感谢, 吉列尔莫

testing统计方法

我为应用程序编写了很多统计方法。 问题是我不知道如何适当地testing它。 例如,在unit testing中,我检查所有分布概率的总和是否收敛到1,但不是1。 例如,所有概率的总和可能是0.9999999甚至1.0000000005,实际值如果强烈取决于分布有多less不同的结果。 也许我可以这样testing value should be less that 1.1 value should be more that 0.9 但我不确定这个testing是否一致,也许有一个分布,由于数值计算会输出1.1 如何正确testing。

如何将node.js合并到javatesting中?

我在看Mercado Libre Java SDK ,注意到他们的资源库中有一个名为“mockapi”的文件夹。 看起来他们已经用JavaScript编写了一个完整的模拟API,用来testing他们的Java客户端。 但是,我还是不太明白它是如何工作的。 我已经发布了一些在app.js中使用的javascript来做到这一点。 var express = require('express'); var fs = require('fs'); var app = express.createServer(); app.configure(function(){ app.use(express.methodOverride()); app.use(express.bodyParser()); }); app.post('/oauth/token', function(req, res) { if(req.query["grant_type"]=="authorization_code") { if(req.query["code"]=="bad code") { res.send({"message":"Error validando el parámetro code","error":"invalid_grant","status":400,"cause":[]}, 400); } else if(req.query["code"]=="valid code without refresh token") { res.send({ "access_token" : "valid token", "token_type" : "bearer", […]

NightwatchJS“冻结”

当我们从Windows迁移到Linux时,我们的Nightwatchtesting不再运行。 它只是冻结。 Selenium服务器已经在监听, chrome_driver (linux 64位)设置正确。 但是,这是我们得到的: $ node nightwatch.js -t tests/mytest.js –verbose [ mytestmodule ] Running: MyTest INFO Request: POST /wd/hub/session – data: {"desiredCapabilities":{"browserName":"chrome","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY"},"sessionId":null} – headers: {"Content-Type":"application/json","Content-Length":129} 任何build议非常感谢。

量angular器JS预处理器

我知道在Karma中有使用预处理器的选项,但是在量angular器中,我看不到同样的东西。 我目前正在使用onPrepare选项,但我想知道是否有可能/目前是否有一种方法来让npm模块总是先运行(基本上与onPrepare相同),但通过configuration,而不必做任何要求等