Tag: 中华

Node.js sinon在并行执行中桩存函数导致失败的testing

我有两个testing用例testing相同的function只是采取两个不同的执行path,所以说明: MyClass.prototype.functionBeingTested = function() { if (this.check1()) { this.isCheck1Called = true; } else if (this.check2()) { this.isCheck1Called = false; } else { … } }; 我的2个testing用例如下: it('should take check1() execution path', function() { var myClass= new MyClass({}, {}, {}); var check1Stub sinon.stub(MyClass.prototype, 'check1'); check1Stub.returns(true); myClass.functionBeingTested(); myClass.isCheck1Called.should.equal(true); }); it('should take check2() execution path', function() { var […]