I never liked writing mocks and a while ago someone here recommended to use FakeWeb. I immediately fell completely in love with FakeWeb. However, I have to wonder if there is a downside to using FakeWeb. It seems like mocks are still much more common, so I wonder what I am missing that's wrong with using FakeWeb instead. Is there a certain kind of error you can't cover with Fakeweb or is it something about the TDD or BDD process?
Downsides to using FakeWeb compared to writing mocks for testing
3.8k Views Asked by ajmurmann At
2
There are 2 best solutions below
Related Questions in RUBY-ON-RAILS
- Rails HABTM: Select everything a that a record 'has'
- Best way to make an HABTM association via console
- dynamically create an ical / ics file from a rails model
- Ruby destroy is not working? Or objects still present?
- NoMethodError: undefined method `update_average_rating' for nil:NilClass
- Select results where joined table contains records with an attribute, but without another
- Showing posts only created when boolean was true
- Ruby on rails and HAML - Print a hash with background color
- How can I monitor an endpoint's status with Ruby?
- How to create dynamic pages without form_for helper in Rails?
- Rails 4.2 jQuery loads only after refresh
- "Access Denied" - User's Permissions to S3 Bucket
- ActiveRecord, Rails 4: has_many :through with scoped conditions failure
- Rails - formatting a list of options
- Rails - Ajax do not work properly on production server
Related Questions in UNIT-TESTING
- How to write tests for classes with inheritance
- PHPunit call magic methods
- Convert IEnumerable to IObservable with variable Period
- How to a run specific code before & after each unit test in Python
- Unit testing a class A that derives from an abstract class B
- Is there another way to unit test business logic in mvc
- Some of my tests show prepended with junit.framework
- Selenium Driver Service not found exception
- Can not convert from Class<PowerMockRunner> to Class<? extends Runner>
- AngularJS Unit Testing - multiple mocks and providers
- How to use Sinon.js FakeXMLHttpRequest with superagent?
- Get Mock with AutoMock.Create<>()
- Mock service that takes unitOfWork in constructor
- Cleanest method for creating a pytest test fixture that takes in dynamic text data
- g++ 5.1.0 not building project, clang shows unknown error
Related Questions in MOCKING
- PHPunit call magic methods
- AngularJS Unit Testing - multiple mocks and providers
- How to use Sinon.js FakeXMLHttpRequest with superagent?
- Automatically wrap C/C++ function at compile-time with annotation
- How to mock specific RequireJs dependencies while unit testing
- Create mock based on existed real instance
- Overriding function with Sinon.mock?
- Spring MockRestServiceServer handling multiple requests to the same URI (auto-discovery)
- Sling Mock is not allowing to get ResourceResolverFactory
- Swift Mocking Class
- How can I mock methods of @InjectMocks class?
- Can I inject primitive variable into mocked class using annotation?
- How to capture field value when a method of a class is called in Python?
- Unit testing a fluent interface with Mockito
- Mocked repository does not trigger as expected
Related Questions in FAKEWEB
- FakeWeb::NetConnectNotAllowedError
- Stub out a request to google maps api in my tests
- Stub a image url and return an image
- undefined method `it' in RSpec::Core::ExampleGroup::Nested_2
- Functionality similar to FakeWeb for Java
- Downsides to using FakeWeb compared to writing mocks for testing
- How to return object instead of string for response with nock?
- ruby Fakeweb error if a Mechanize agent's read_timeout= is called
- Overwriting http.request with EventEmitter
- List of URIs registered to FakeWeb
- Library like fakeweb for Python
- Testing that HTTP-request is not made in Rails
- How to write a test to specify the format of a http request in ruby?
- In Python, are there any libraries that mock out responses for httplib?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You should take a look at WebMock http://github.com/bblimke/webmock
The downside of mocking http requests is the lack of protection against remote API changes. If remote HTTP service changes, and your code won't be compatible anymore, your tests won't tell you about it. If you mock http client methods on your own, you have the same problems. It's good to have some integration test suite which verifies that your code can still talk to real http service.
The advantage of library like FakeWeb or WebMock is the fact that you can focus on implementing behaviour instead of worrying about implementation details of specific http client library. Even if you change library from for example Net::HTTP to RestClient, the behaviour should still be preserved so the tests should still be passing. If you mock http client on your own, you have to change tests when you change implementation, even if behaviour didn't change. Using FakeWeb or Webmock also helps with TDD or BDD (test first). You can specify the http behaviour with specs or tests, before worrying about implementation details of specific http client.