Questions tagged [stub]

A replacement implementation for objects, methods, or functions in order to remove external dependencies, or the object at the client end of an RPC or RMI invocation.

A replacement implementation for object, method, or function. The typical types of stubs are:

  • Testing stubs that remove external dependencies. They are typically used during unit and component testing. If you're trying to write a unit test and need to replace a simple call to a database, external libraries (e.g., file I/O) or other system API, stubbing might be perfectly suited for your needs.
  • RPC (CORBA, RMI, web service) stubs forward the call to remote service where it is handled; the answer, if any, is returned to the calling side. They implement the same interface that is implemented by the servicing object on remote side (may also implement additional interfaces).
  • Dummy stubs are empty placeholders for objects, methods or functions that are supposed to be completed later. They allow the current code to compile so that other, already finished parts could be tested. Such stubs are used when implementing a very large libraries following some already specified API.

A mock is somewhat similar to the testing stub but is not considered stub as it is a special purpose object capable of registering that has been called on it. It does not take other actions (a generally unfavoured partial mock does forwards execution of some methods to underlying object).

1108 questions
0
votes
1 answer

Android Bind service call Interface issue`

I am facing an error while binding the service with interface stub(). Here is my Connection code: class LogConnection implements ServiceConnection { public void onServiceConnected(ComponentName className, IBinder boundService) { …
NovusMobile
  • 1,813
  • 2
  • 21
  • 48
0
votes
1 answer

mocking stub deep legacy objects

I am not sure I still get how to "unit" test legacy code such as this... Most of my code is to put things and remove things from an object of class A that has a number of other objects inside it and so on like a tree. At the leaf of this tree is a…
treefrog
  • 1,027
  • 1
  • 15
  • 30
0
votes
2 answers

Stubbing model attributes in controller tests

I am finding it very hard to stub certain attributes of a model on a controller test. I want to make sure to stub as little as possible. EDIT: I have been demoved of using stubs for such integration. I understood that the stubs won't reach the…
josemota
  • 974
  • 1
  • 8
  • 27
0
votes
1 answer

How update stub class? (axis2)

I created a web service with eclipse indigo, tomcat 7 and i used the axis2. I did a simple calculator for tests and i generate the results using the stub class. All works. The problem is when add a new method in the web service. This new method…
Thiago C. S Ventura
  • 2,448
  • 1
  • 29
  • 43
0
votes
1 answer

Why is the stubbed method not called?

It seems I understood something wrong. I have a class module Spree class OmnikassaPaymentResponse #... # Finds a payment with provided parameters trough ActiveRecord. def payment(state = :processing) Spree::Payment.find(:first,…
berkes
  • 26,996
  • 27
  • 115
  • 206
-1
votes
1 answer

TimeOut Setting while Accessing .net Web Service

I have developed a Mobile Application for E5 Mobile, Here in my Application I am using .net Web Services for login & other activity. I have created stubs accordingly. My Application is running fine. Now My Problem is that sometime because of…
Lucifer
  • 29,392
  • 25
  • 90
  • 143
-1
votes
1 answer

java client web-server connect to multi web-server

I have to do an implementation for a class in the Java language by using Tomcat 7 and Axis2 under Ubuntu 11.10 32bit. The requirement is to make a dynamic web-server project for simple registration, register and unregister course. Also, each faculty…
user8580
  • 13
  • 2
-1
votes
1 answer

Unit testing on imported package

I am currently creating unit testing for a project, i need to test a function that have dependency injection without interface from an entity. Here is the code func (u UserUsecase) CreateUser(ctx context.Context, p request.StoreUser) (entity.User,…
-1
votes
1 answer

Rspec assertion doesn't make sense: Double received unexpected message with

Here's a minimally reproducible example, you can just copy this and run it with the latest version of gem install rspec. #class Bar # def run_bar(a:, b:) # return # end #end def foo(bar) if bar != nil bar.run_bar(a: "test", b: {}) …
notacorn
  • 3,526
  • 4
  • 30
  • 60
-1
votes
1 answer

How to mock ftp.nlst() in unit tests?

I'm trying to get my unit tests working, especially this ftp.nlst def get_file_list(ftp_conn): filematch = '*.csv' ftp_list = ftp_conn.nlst(filematch) return ftp_list Can someone help with the unittest below? Thanks. from…
wawawa
  • 2,835
  • 6
  • 44
  • 105
-1
votes
1 answer

How to create stubs for Karma/jasmine testing in Angular

Any one can explain how to create Stubs for service mocking for Angular Karma testing. Please provide any complete example or link. After creating the stub, how to write the test cases using stub data. Please explain. Spy Vs stub which one is best…
YYY
  • 3,440
  • 5
  • 20
  • 24
-1
votes
1 answer

How to stub a configuration for some tests

I have config.iafis_soap_enabled = false in test.rb file. In some cases I want it to be true, how can I stub it?
Asnad Atta
  • 3,855
  • 1
  • 32
  • 49
-1
votes
1 answer

Mockito verifying method invocation without using equals method

While using Spock i can do something like this: when: 12.times {mailSender.send("blabla", "subject", "content")} then: 12 * javaMailSender.send(_) When i tried to do same in…
minizibi
  • 653
  • 3
  • 13
  • 28
-1
votes
1 answer

Why do I get an UnifnishedStubException in Mockito when the stub looks as per documentation?

I have the following test file using Mockito framework: @Rule public ExpectedException expectedException = ExpectedException.none(); @Spy private JarExtracter jExt = Mockito.spy(JarExtracter.class); @Test public void…
Vlad Balanescu
  • 664
  • 5
  • 27
1 2 3
73
74