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
1
vote
1 answer

What's the conventional location for storing stub classes?

I have a system under test and I need to create some stub classes to isolate my SUT. I'm using NetBeans and my question is, should the test classes be saved in the test folder along with the test class or in the main package next to the stubee(?)? I…
Sara Bahis
  • 71
  • 4
1
vote
3 answers

Mock only one method on PHPSpec stubs

Okay, so I'm trying to move one of my packages over to PHPSpec tests, but soon I ran into this problem. The packages is a shoppingcart package, so I want to test that when you add two items to the cart, the cart has a count of two, simple. But of…
Crinsane
  • 818
  • 3
  • 16
  • 28
1
vote
0 answers

Calabash Android Network Stubbing

I am trying to test an android app using calabash-android, and since network requests usually take time on my internet connection, I want to stub the request in such a way that the data the actual request receives (a JSON string) is available…
Sameer Deshmukh
  • 138
  • 1
  • 8
1
vote
2 answers

When should I stub out a type by manually creating a "stub" version, rather than using a mocking framework

Are there any circumstances where it is favourable to manually create a stub type, as opposed to using a mocking framework (such as Rhino Mocks) at the point of test. We take both these approaches in our projects. My gut feel when I look at the long…
Ben Aston
  • 53,718
  • 65
  • 205
  • 331
1
vote
1 answer

Overwrite Javascript prototype with stub functions

I'm trying to run an A/B test for a new feature I'm adding to a website. In the past, our team has done something like this before showing various features on the page: someUserActionThatEnablesFeature:function(){ …
Daniel
  • 1,789
  • 17
  • 15
1
vote
1 answer

Expected spy but got function error message with Sinon stubs?

I have the following test suite: describe('rendering Bundle View', function () { beforeEach(function () { this.view = new Backbone.View(); this.renderStub = Sinon.stub(this.view, 'render', function () { this.el =…
gofishus
  • 11
  • 4
1
vote
1 answer

Are there any tools that can generate stubs in WCF based on a XSD?

I'm currently writing a stub for a quoting service so that I can continue writing my application. I have a copy of the xsd that the service will request and respond with. I was thinking about manually creating a WCF service which returns objects…
user1838438
  • 155
  • 5
1
vote
2 answers

Do contract tests necessary imply stubs?

Recently, I've been reading a lot of articles (mostly from J.B. Rainsberger) about contract and collaborative tests. In order to get it into it, I've started a small project. From my understanding, the responsiblity of a contract test is to ensure…
Francis Toth
  • 1,595
  • 1
  • 11
  • 23
1
vote
0 answers

Generating Websphere 7 stubs with Maven 2

Does anyone know how to generate the rmi stubs for websphere 7 using Maven 2? I have found a websphere 6 maven plugin, but not sure that it would be compatible and it is quite old.
Doug Saus
  • 49
  • 1
  • 6
0
votes
2 answers

Rails isolated tests running under rails env

I'm currently working on a project and we started migrating our tests to isolated test (no rails dependency, and using stubs and mocks). The thing is that until all the current tests are being isolated, we have to run the tests together with the…
0
votes
2 answers

Unit test class with stubs. Should I configure stubs to return ALWAYS correct values?

this is one of my questions about unit testing. I'm reading The Art Of Unit Testing and at chapter 3 the author shows how to remove dependency between one or more classes. That seems clear to me. What's not absolutely clear is the following…
Marconline
  • 1,108
  • 12
  • 30
0
votes
1 answer

Mountebank: Ability to add names for stubs

Is there a way to tag stubs of an imposter with some identifiers so that while debugging, we can easily get the matches for a specific stub? Currently the stub has a matches field, but when we want to verify programmatically if a certain stub has…
Aravindh S
  • 1,185
  • 11
  • 19
0
votes
1 answer

Error in reshape long multiple variables

I have to reshape my dataset from wide to long. I have 500 variables that range from 2016 to 2007 and are recorded as abcd2016 and so on. I needed a procedure that allowed me to reshape without writing all the variables' names and I run: unab vars :…
Macrina
  • 25
  • 8
0
votes
1 answer

Tcl8.6.5 USE_TCL_STUBS tclDecls.h # undef Tcl_StaticPackage,

I am trying to rebuild some software originally built against Tcl/Tk8.2 which used the libtclstubs.a and libtkstubs.a static libraries. Now I am able to recompile against -ltclstub8.6 -ltkstub8.6 from the Ubuntu Xenial, tcl8.6-dev:amd64 …
doobs
  • 11
  • 3
0
votes
1 answer

Microsoft Fakes - Stubbing an Extension Method Shouldn't Work But It Does

I have an interface, ILoader, on which I have defined an extension method CheckLoaderDatabaseConnection: //the extension method public static class LoaderExtensions { public static void CheckLoaderDatabaseConnection(this ILoader loader) …