Skip to main content

Questions tagged [stub]

5 votes
3 answers
2k views

In the process of refactoring non-testable code we are re-designing some of ours classes so that it can be easily replaced by a stub or mock during unit tests. Here is an example of such class (...
Delgan's user avatar
  • 376
0 votes
3 answers
2k views

In The Art of Unit Testing, 2nd Ed., the author gives the following example for injecting a stub using constructor injection and a "fake object". The goal of the "fake object" is to inherit the ...
8protons's user avatar
  • 1,389
125 votes
9 answers
54k views

As I understand, the point of unit tests is to test units of code in isolation. This means, that: They should not break by any unrelated code change elsewhere in the codebase. Only one unit test ...
Alex Lomia's user avatar
  • 1,351
0 votes
1 answer
318 views

I'm trying to get into TDD, and a lot of examples sugests that we should use stubs to make our code more flexible. If I'm using javascript (for example) then why should I use stubs, since methods and ...
julianomontini's user avatar
14 votes
4 answers
2k views

Some time ago I read, on a Stack Overflow answer that I can't find, a sentence that explained that you should test public APIs, and the author said that you should test interfaces. The author also ...
Christopher Francisco's user avatar
0 votes
2 answers
950 views

I have some methods im trying to test which use a StreamReader dependency that i mock using Rhino mocks. But it is a large xmlFile. In the spirit of unit testing im trying to keep away from using a ...
Mr. MonoChrome's user avatar
0 votes
2 answers
316 views

In Chapter 3 of his book The Art of Unit Testing: with Examples in C#, Roy Osherove illustrates the issue of undesirable external dependencies in code under test. He shows this with a method named ...
Isaac Kleinman's user avatar
0 votes
4 answers
4k views

I'm like doing TDD so I started everything mocking objects, creating interface, stubbing, great. The design seems to work, now I'll implement the stuff, a lot of the code used in the stubs are going ...
jjchiw's user avatar
  • 119

15 30 50 per page