-
Notifications
You must be signed in to change notification settings - Fork 733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to make this library more test friendly? #316
Comments
I'd use something like Mockito for that purpose. Are there some specific use cases where that doesn't work nicely? Constructors with attributes will go quickly out of control with a big object like Another idea is to provide a |
If I make a mock object, I'll have to look at github-api source code and
mock tons of methods. My tests end up being pretty brittle as they have to
know the implementation of how I use this library's classes in my business
logic.
You can use static constructors for classes with few attributes and the
builder pattern for bigger ones to make immutable objects, i.e. they don't
have to have setters.
Does this make sense? I can provide an example of how using a mock can be
brittle and a bit tedious.
…On Sat, Nov 26, 2016 at 6:02 PM Kohsuke Kawaguchi ***@***.***> wrote:
I'd use something like Mockito <http://site.mockito.org/> for that
purpose. Are there some specific use cases where that doesn't work nicely?
Constructors with attributes will go quickly out of control with a big
object like GHRepository, and I hate making these objects mutable.
Another idea is to provide a HttpConnector that records & replays the
HTTP calls into/from a file, which eliminates the need for a long & verbose
mock object setups.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#316 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAdVbXI1XB_GquoZK8aOMfBtsiFulFh9ks5rCLqbgaJpZM4K88SJ>
.
|
@davidxia please let me know if you decide to make spotify/github-api |
@davidxia I'm not trying to claim that mock is perfect, but I don't see a big difference between mock vs static construction. In both cases, you'd have to construct an object graph with every attribute your business logic uses. And thinking about creating all the builders for each of the That's why I suggested a replay at HTTP layers. That way, people writing tests will use actual captured JSON payloads, and I don't need to write all the builders. |
Added WireMock facility working great. |
Thanks for this library.
I'm trying to write unit tests that use objects like
GHRepository
, but I'm having a hard time creating aGHRepository
instance with dummy data. There are no static constructors. It looks like the only way to create one with attributes is to deserialize from a JSON string with anObjectMapper
.Can we make this library more test friendly?
The text was updated successfully, but these errors were encountered: