Skip to content
This repository was archived by the owner on Oct 21, 2018. It is now read-only.

Changed the default return value for methods that return a collection interface to return an instance of an empty collection#11

Open
GustavoRusso wants to merge 1 commit intoayende:masterfrom
GustavoRusso:master
Open

Changed the default return value for methods that return a collection interface to return an instance of an empty collection#11
GustavoRusso wants to merge 1 commit intoayende:masterfrom
GustavoRusso:master

Conversation

@GustavoRusso
Copy link

This change tries to reduce the number of methods stubs needed to stub an object.

The reason why we use a stub is to communicate that the object is needed but does not act for the purpose that we want to test.

Currently, if there is a call to a method of a stub that returns a collection, the stub object will return a null that will probably cause a null reference exception.
We will have to add a stub espectation for the method even if it does not act on what we want to test.

It is usual that the real implementation of a method that return a collection, return a empty collection instead of a null.

Therefore, if the stub object returns an empty collection instead of a null, will be more similar to the real behavior of the real class, and in addition, it will prevent the need of additional stub calls.

…stance of an empty collection when the method have no expectations. It will avoid the need to stub methods that returns collections just to avoid null reference exceptions when the method does not matter in the test
@alaendle
Copy link

Even if it's a breaking change - i'll guess it would be useful to return stubs for this interfaces. +1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants