stub

    0熱度

    1回答

    我試圖模擬一個節點模塊內的功能。但它不允許我。有任何想法嗎? // module A function foo(){ return 1; } function bar(){ return foo() + 1; } module.exports = {foo, bar} 在測試中... const a = require('a'); ... sinon.s

    1熱度

    2回答

    使用RSpec的RSpec的存根同樣的方法,我想: expect(Thing).to receive(:status) .with(for: 'something') .and_return('down') 在第一次循環,和相同的存根應返回2號迭代不同的回報: expect(Thing).to receive(:status) .with(for

    0熱度

    2回答

    在我的生產代碼中,我有一個阻塞程序爲10 ms的函數(因爲使用execSync)。在我的測試我使用testdouble.js庫存根它: td.when(getSignalStrength()).thenReturn.apply(null, array); 但是短線會立即響應,並在現實功能getCurrentSignalStrength持續10毫秒響應。我想延遲存根的答案,所以測試會更接近現實。

    0熱度

    2回答

    這是我的僞類,我想測試: class Meter: def __init__(self, meterInfo): self.b1pos = meterInfo['b1pos'] def setMeter(self): print 'Initializing' try: print 'Connecting' ex

    0熱度

    1回答

    如何使用Sinon.JS測試如下功能? export function getToken(done) { const kc = Keycloak(config) kc.init({ onLoad: 'login-required' }) .success(authenticated => { authenticated ? done(null, kc.to

    0熱度

    1回答

    在代碼中,我使用了Python方法time(): from time import time # Some code t=time() # Some more code main.py 在我的測試,我想存根有時間的Mockito的方法,總是返回相同的值: import time #... when(time).time().thenReturn(2) #... test.py

    0熱度

    1回答

    我有一個控制器動作欲測試: LOG = ApiRequest::Resource::Login def create @response = LOG.new(current_user, params: params).create return if request_failed? ... end def request_failed? if @r

    0熱度

    1回答

    我想砸自己的功能,並返回不同的ARGS不同的價值,這機能的研究使用一個回調 例如: function saop(){ saop.get('car',"http://webservice.com",function (err, result) {}); // (null, {car:"car"}) saop.get('house',"http://webservice.com",functio

    0熱度

    1回答

    我有多個使用共享基礎文件(稱爲testBase.js)的Mocha測試文件。它負責建立所有的存根和間諜。 如果我運行通過摩卡個人文件中的所有測試用例通過但當它貫穿摩卡測試* .js文件,測試案例開始出現故障,提高錯誤 TypeError: Attempted to wrap send which is already wrapped 這裏是我的beforeEach和afterEach塊 bef

    0熱度

    1回答

    此webmock存根請求在運行測試時不起作用。這是控制器。 class AdvisorDashboardController < ApplicationController load_and_authorize_resource :class => AdvisorDashboardController require 'Numeric.rb' include Appl