stub

How can I stub IDBconnection

人走茶凉 提交于 2019-12-13 05:01:08
问题 I am writting Unit Test for my database connection. I have following class Public class A { public IDbConnection _dbConnection; public A() { _dbConnection = new SqlConnection(connectionStringName); } public int ExecuteNoneQuery(CommandDefination command) { return _dbConnection.Execute(command); } } I want to test this class, how I can test with Microsoft Stub/Shim I have written following code, but it is not working. [TestMethod] public void TestMethod1() { StubIDbConnection stubIDbConnection

Installing .NET framework from USB drive when necessary

北城余情 提交于 2019-12-13 03:49:56
问题 We have a .NET application that will be distributed through USB drive. End users will connect the drive and double click on the EXE (a .NET exe) to run it WITHOUT installing it. Now the problem is, if .NET is not installed we would like to trigger the .NET installer instead of showing the default download message that MS has put there. The installer will be distributed with the application through the USB. One way to do it might be by replacing the PE stub file in the .NET executable. But I

stub an instance variable using mocha

亡梦爱人 提交于 2019-12-13 03:38:30
问题 Let's say I have a method that references an instance variable directly: class MyClass def method1 puts @instance_var end end How can I stub out the value of @instance_var using mocha in a Test::Unit test? 回答1: You can't. That's one of the many reasons why you should never access ivars directly. 来源: https://stackoverflow.com/questions/9971192/stub-an-instance-variable-using-mocha

Not able to Switch Windows using stub and spy using Cypress

a 夏天 提交于 2019-12-13 03:26:01
问题 I am facing Issue in switching windows within my CRM web Application using Stub methods. Getting below error message Timed out retrying: { [Function: open] callBaseMethod: { [Function] callBaseMethod: [Circular], getBaseMethod: { [Function] callBaseMethod: [Circular], getBaseMethod: [Circular], resolveInheritance: [Circular], registerEnum: [Circular] }, registerEnum: [Circular] } } is not a spy or a call to a spy! Because this error occurred during a 'before each' hook we are skipping the

currentSpec in Jasmine 2 is undefined

纵饮孤独 提交于 2019-12-13 02:34:56
问题 I want to upgrade my test suite to the latest Jasmine version 2.3.4. I have some custom helper methods for testing AngularJS stuff inside my spy_helper.js like this: (function() { this.stubPromise = function(service, functionName) { var $q = jasmine.getEnv().currentSpec.$injector.get("$q") var $rootScope = jasmine.getEnv().currentSpec.$injector.get("$rootScope") var deferred = $q.defer(); var spy = spyOn(service, functionName).andReturn(deferred.promise); spy.andResolveWith = function(value)

What is the difference between mocks and stubs ( JMock)

人走茶凉 提交于 2019-12-13 01:17:56
问题 What is the difference between mocks and stubs in jMock? I can create both with jMock? how i can create stubs with it and what the situation is most appropriate for this, I believe that using stubs is when I need to prepare some state for test. Thanks 回答1: Wikipedia has an article regarding Mock objects, but the terminology is not explained as good as could be. We used to make this distinction (which may be subject to discussion, of course): Mocks and stubs both simulate an object which is

Stub (…) received unexpected message (…) with (no args)

巧了我就是萌 提交于 2019-12-12 20:25:22
问题 I try to write a test using RR. What I need is a stub of a model object. describe ApplicationController do subject(:application_controller) { ApplicationController.new } let(:messages) { ['a1', 'a2', 'a3' ] } let(:model) { Object.new } it 'should copy errors to flash' do stub(model).error_messages { messages } flash[:error] == nil subject.copy_errors_to_flash(model) flash[:error].should == messages end end What I get is ApplicationController should copy errors to flash Failure/Error: stub

Software engineering with Ada: stubs; separate and compilation units [closed]

断了今生、忘了曾经 提交于 2019-12-12 12:15:37
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I'm with a mechanical engineering background but I'm interested to learn good software engineering practice with Ada. I have a few queries. Q1. If I understand correctly then someone can just write a package specification (ads) file, compile it and then compile the main program

How can I stub rand in minitest?

一笑奈何 提交于 2019-12-12 12:12:29
问题 I've tried Random.stub :rand, 1 do ... end and Kernel.stub :rand, 1 do ... end and Class.stub :rand, 1 do ... end (because when I run self.class where I run rand(2) I get Class ). I've also tried replacing rand(2) with Random.rand(2) but it doesn't help. So how do I stub out rand? 回答1: rand is part of the Kernel module that is mixed into every class. To stub it, you need to call stub on the object where rand is being called. It's probably easiest to see in an example. In the following code,

Stub sleep with RSpec

与世无争的帅哥 提交于 2019-12-12 03:18:37
问题 I have the following code in my app: def timeout_tasks 10.times do # Work... sleep 2 end end I would like to test this method, but need to stub sleep to I don't have to wait that much for the test to finish. How can I do this? I am aware of the allow(Object).to receive(:sleep) but I'm not sure what the Object is. Or is there any other better approach? 回答1: You should stub sleep on the object it is called on Eg. class SleepTest def sleep_method sleep 2 end end And in your test sleep_test =