Questions tagged [stubs]

A stub is a small piece of code that takes the place of another component during testing.

A stub is a small piece of code that takes the place of another component during testing. The benefit of using a stub is that it returns consistent results, making the test easier to write. And you can run tests even if the other components are not working yet.

89 questions
0
votes
1 answer

Minitest stub_any_instance and methods?

If I do Klass.stub_any_instance(:new, raise(RuntimeError) do ... end the RuntimeError is raised at the stub_any_instance line and not, as I would like, later when a Klass.new() occurs. Is there a way to make this work the way I would like?
Paul D Smith
  • 639
  • 5
  • 16
0
votes
2 answers

How stub functions in C++ are used are replaced by shared library functions

I am new to how C++ stubs functions are used . I went through the link How to create stub shared libraries on Linux but 1) I could not get exact complete example code in c++ in which stubs are written in C++ code . If someone can point me to…
TechEnthusiast
  • 273
  • 4
  • 18
0
votes
0 answers

How to Mock ExecuteReader method?

I'm new to moq and setting up mocks so i could do with a little help. How do I mock up an ExecuteReader() using Moq? Update I have below code for ExecuteReader private void ExecuteGainLossCommand(AccountsContext dbContext, string query,…
Ajinkya Kasar
  • 3
  • 1
  • 1
  • 3
0
votes
0 answers

EJB 1.1 stubs generation in RAD9

Am working on legacy code which EJB v1.1. Due to RAD version issues we could not migrate complete code to compatibility level of RAD 9. So am trying generate stubs for EJB 1.1 using ejbdeploy manually so i can still use these projects in RAD 9. When…
Amit Naik
  • 983
  • 1
  • 5
  • 16
0
votes
1 answer

Maven repository for WSO2-IS service stubs?

In what Maven repository can I find the various (SOAP) service stubs that ship with WSO2 Identity Server 5.1.0? The stubs themselves ship with WSO2 Identity Server, in the directory /repository/components/plugins/. The OAuth stubs for example are…
Guus
  • 2,986
  • 2
  • 21
  • 32
0
votes
3 answers

How to test a hard coded class using a fake in MiniTest

I have a PlantTree job that calls a PlantTree service object. I would like to test the job to ascertain that it instantiates the PlantTree service with a tree argument and calls the call method. I'm not interested in what the service does or the…
Jumbalaya Wanton
  • 1,601
  • 1
  • 25
  • 47
0
votes
1 answer

Need to Stub a Function that takes a Func<> as a Parameter

I have a method on my data access layer that can take any function as search criteria and run this against our Entity Framework entities. I am trying to create unit tests using Rhino Mocks on the business layer, but this calls the DAL method. When…
ChristyPiffat
  • 359
  • 1
  • 6
  • 26
0
votes
1 answer

How to stub method that doesn't belong to class in RSpec?

I'm working a project that uses a notify method that does does not belong to a method. I want to stub this method to help speed up my spec and keep my log clean. How can i do this? lib/notify.rb require 'json' require 'rest-client' def…
Antarr Byrd
  • 24,863
  • 33
  • 100
  • 188
0
votes
0 answers

Rspec Stub Application Controller Methods

I'm using omniauth at my rails app (4.2, ruby 2.2.1) and I defined this controller here: class ApplicationController < ActionController::Base protect_from_forgery with: :exception helper_method :current_user, :logged_in? def logged_in? …
Igor_Marques
  • 1,742
  • 2
  • 16
  • 24
0
votes
1 answer

Use a single fake as both a mock and a stub

I am pretty familiar with unit testing and do understand the difference between mocks and stubs. The simplest explanation from Roy Osherove is that all fakes start out as stubs until you assert against them, then they are mocks. Again, I get all…
Scott Marcus
  • 64,069
  • 6
  • 49
  • 71
0
votes
1 answer

Cannot import webservice stubs in client

I am trying to learn about jax-ws and created a simple Bottom-Up HelloWorld webservice in order to train myself: import org.jboss.annotation.ejb.LocalBinding; import javax.ejb.Remote; import javax.ejb.Stateless; import javax.jws.WebMethod; import…
thorwinn
  • 73
  • 1
  • 6
0
votes
2 answers

Using stubs in a basic Java maven project

I have a basic maven project with the folder structure: -main and -test directories. I have one package in the main source directory which consists of a few classes, say a.class b.class and c.class, all under the same package. All classes have…
0
votes
1 answer

Simple RMI application with client-side exception

I use Java 8 and I created a simple RMI application but I have a client-side exception that I don't understand. Using Eclipse the structure of my application is: ---RMI_project …
Fobi
  • 435
  • 1
  • 7
  • 17
0
votes
1 answer

Stub Active Record count with parameter

I'm struggling to figure out how to stub the following: def max_post_limit Post.on(date).count > some_limit end I'm trying to stub the Post... section, not the method. So far I have tried the following and similar variations. All return either…
user2420484
  • 123
  • 1
  • 7
0
votes
1 answer

testing with mocks and doubles being treated like methods

I have introduced mocks and and stubs into my testing and all was going well. I have hit a bit of a wall because since changing the code to test further i am getting the following error in rspec but i cannot understand why it is coming up with…
Lilp
  • 961
  • 1
  • 11
  • 31