stub

Amazon S3 standalone stub server

I seem to recall reading about an Amazon S3-compatible test server that you could run on your own server for unit tests or whatever. However, I've just exhausted my patience looking for this with both Google and AWS. Does such a thing exist? If not, I think I'll write one. Note: I'm asking about Amazon S3 (the storage system) rather tha...

Is conditional compilation a valid mock/stub strategy for unit testing?

In a recent question on stubbing, many answers suggested C# interfaces or delegates for implementing stubs, but one answer suggested using conditional compilation, retaining static binding in the production code. This answer was modded -2 at the time of reading, so at least 2 people really thought this was a wrong answer. Perhaps misus...

Parsing C++ to generate unit test stubs

I've recently been trying to create units tests for some legacy code. I've been taking the approach of using the linker to show me which functions cause link errors, greping the source to find the definition and creating a stub from that. Is there an easier way? Is there some kind of C++ parser that can give me class definitions, in ...

rspec: How to stub an instance method called by constructor?

class A def initialize @x = do_something end def do_something 42 end end How can I stub do_something in rspec, before the original implementation is called (thus assigning 42 to @x)? And without changing the implementation, of course. ...

Is it possible to generate partial stubs with Rhino Mocks?

I am new to unittesting and mocking in general and am trying to set up tests for one of my classes where I want to make sure that a particular method is called from another method within the same class. I would therefore like to use the concrete implementation but mock out parts of it. Is this possible? public class MyClass { public ...

Automatic generation of function stubs

Is there any Visual Studio add-on (or windows/unix stand-alone program) that creates stub implementations in the cpp file for the functions (including class member functions) that are defined in the header file? ...

What is a "Stub"?

So, carrying on with my new years resolution to get more in to TDD, I am now starting to work more with Rhino Mocks. One thing I am keen to do is to make sure I really grok what I am getting in to, so I wanted to check my understanding of what I have seen so far (and I thought it would be good to get it up here as a resource). What is ...

What is Your Tool-of-Choice for Creating Stubs?

Following on from my last question "What is a "Stub", I would really like to sit down tonight and play more with creating stub objects. What is your tool of choice for creating Stub objects? And for bonus points :) Can you also link to any good tutorials for getting started with them? Thanks a lot guys and girls, appreciated :) FYI...

TDD: Stub, Mock, or None of the Above

Hello, I'm trying to learn TDD by applying it to a simple project of mine. Some details (and an earlier question) are here: http://stackoverflow.com/questions/473679/tdd-help-with-writing-testable-class The specifics are I have a PurchaseOrderCollection class that has a private List of PurchaseOrders (passed in at constructor), and t...

Generate a C# delegate method stub

Anyone know how to automatically create a delegate stub method? In WPF it seems im constantly having to pass delegates around. i would like to be able to type a method name that doesnt exist and have a method stub automatically generated...currently i'am having to constantly reference the docs to get the delegate signature and then manu...

Stubbing objects with input arguments

So, I'm trying to stub a database connector in order to write tests for it. The problem is that the database connector is a pretty thin layer, and the queries to it are somewhat open-ended. I want my code to be able to ask for a variable from the database, and the connector should be OK with this. The signature for this call looks someth...

externalizing junit stub objects.

Hi!    In my project we created stub files for testing junits in java(factories) itself. However, we have to externalize these stubs. After seeing a number of serializers/deserializers, we settled on using XStream to serialize and deserialize these stub objects. XStream works like a charm. Its pretty good at what it claims to be. Previ...

Is it legal to stub the #class method of a Mock object when using RSpec in a Ruby on Rails application?

I would like to stub the #class method of a mock object: describe Letter do before(:each) do @john = mock("John") @john.stub!(:id).and_return(5) @john.stub!(:class).and_return(Person) # is this ok? @john.stub!(:name).and_return("John F.") Person.stub!(:find).and_return(@john) end it.should "have a valid #to fi...

Installing .NET framework from USB drive when necessary.

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. ...

Access restriction on class due to restriction on required library rt.jar?

I'm attempting to compile Java 1.4 code that was created by IBM's WSDL2Java on Java5 without recreating the stubs and saw this error in Eclipse. I'm under the assumption that the stubs created should just compile as long as the runtime jars are available (they are). Access restriction: The type QName is not accessible due to restriction...

How to stub/mock JDBC ResultSet to work both with Java 5 and 6?

Hi, I'm testing some of my classes working with JDBC statements etc and now I got problem with JDBC ResultSet interface: The software should run both with Java 5 and Java 6 and hence the tests should also be run with both versions. Unfortunately Java 6 has introduced a bunch of new methods (which is still not a big deal) that return a ...

Mocking a method that returns a sealed class in RhinoMocks

Running this code: _foo = MockRepository.GenerateStub<IBar>(); _foo.Stub(x => x.Foo()).Return("sdf"); When public interface IBar { string Foo(); } public class Bar : IBar { public string Foo() { throw new NotImplementedException(); } } throws NotSupportedException - "Can't create mocks of sealed classes". I under...

Library to create java stubs for webservice.

Hello. I would like to know if anyone can recommend a good library to generate java webservices stubs as clients. Currently I'm using a product which has embedded a generator which only needs the WSDL and then creates the needed classes and methods. My problems is it throws warnings and doesn't create any method for some webservic...

Django unit testing with date/time-based objects

Suppose I have the following Event model: from django.db import models import datetime class Event(models.Model): date_start = models.DateField() date_end = models.DateField() def is_over(self): return datetime.date.today() > self.date_end I want to test Event.is_over() by creating an Event that ends in the futur...

How do you stub an individual method in java for unit testing?

I've got a method in a class that's writing to some string, which calls another method which does the same. Something like: void foo() { a += "xyx"; bar(); } void bar() { a += "abc"; } For unit testing purposes, I want to test foo and bar separately. Is there any way to prevent bar from being run when I call foo() or to replace...