Skip to content

Conversation

@brandur
Copy link
Contributor

@brandur brandur commented Jun 22, 2017

Move to using an external API stub in the test suite instead of issuing live API calls so that we can have tests that run more quickly and more reliably.

For the time being, I've just converted the plan test suite over to use the new scheme.

This is an experimental prototype for demonstrative purposes and should not be merged.

See also:

public void testPlanList() throws StripeException {
PlanCollection plans = Plan.all(null);
assertEquals(1, plans.getData().size());
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional tests change to just a simple test for ever supported API operation on a resource. Response data is generated anyway, so we don't assert strongly against it. Instead we just check that it's the basic format that we expected which tells us that we called the right URL and were able to deserialize the response.

String data = getFixture("/v1/subscriptions/sub_123", expansions);
Subscription object = APIResource.GSON.fromJson(data, Subscription.class);
assertNotNull(object);
assertNotNull(object.getCustomer());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what most model tests will look like: one "basic" test that just tries to deserialize a fixture and one "expansions" test that uses the special * to tell the stub that we want every expandable field expanded. We then try to deserialize the response to make sure that all our ExpandableField instances run. I do a basic assertNotNull on a single expandable field as well just as a basic check that it did something.

}

return readUntilEnd(conn.getInputStream());
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs cleanup and comments.

Move to using an external API stub in the test suite instead of issuing live API calls so that we can have tests that run more quickly and more reliably.

For the time being, I've just converted the plan test suite over to use the new scheme.

This is an experimental prototype for demonstrative purposes and should not be merged.

See also:

* stripe/stripe-go#424
* stripe/stripe-php#357
* stripe/stripe-ruby#553
@kjc-stripe
Copy link
Contributor

@brandur Is this PR ready to merge? I'm going to be doing some work on the library over the next two days and would love the newer, faster test suite. Let me know.

@brandur-stripe
Copy link
Contributor

@kjc-stripe Good question! So far most of the stripestub-related feedback has been quite positive. It needs a little more work (I'd like to get parameter validation working) before going mainstream, and I should write a slightly more comprehensive installation guide, but it's also not too far off.

If you think it'd helpful for your hackathon project, I'm definitely open to bringing this in and iterating in parallel to get everything back into an acceptable place. It's worth nothing though that to get the new speed advantages, it's necessarily to convert test suites over to the new base class and conventions one by one (as is done for plan here). That might be something you're doing anyway for your hackathon project though ...

@ob-stripe
Copy link
Contributor

Closing this one in favor of #452.

@ob-stripe ob-stripe closed this May 31, 2018
@ob-stripe ob-stripe deleted the brandur-stripestub branch April 10, 2019 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants