Skip to content
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

Add rule for mockserver #48

Merged
merged 7 commits into from Oct 19, 2018
Merged

Add rule for mockserver #48

merged 7 commits into from Oct 19, 2018

Conversation

thywen
Copy link
Contributor

@thywen thywen commented Oct 2, 2018

This PR adds a Rule for using the Mockwebserver.

This makes it easier and less verbose to add mock server requests

@thywen thywen requested a review from dkaravias October 2, 2018 12:08
Copy link
Contributor

@dkaravias dkaravias left a comment

Choose a reason for hiding this comment

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

Nice additions, just a couple questions

class MockServerTestRule<T : Activity>(
activityClass: Class<T>?,
initialTouchMode: Boolean,
launchActivity: Boolean) : ActivityTestRule<T>(activityClass, initialTouchMode, launchActivity) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this?

App.Companion.component = appComponent
mockWebServer.play(port)
}
var activityRule: MockServerTestRule<MainActivity> = activityTestRule
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the MockServer and MainActivity know about each other?
An alternative could be to keep separate rules and chain them as needed, to keep them more flexible too


@get:Rule
var activityRule: MockServerTestRule<MainActivity> = activityTestRule
var chain: TestRule = RuleChain.outerRule(activityTestRule)
.around(mockServerTestRule)
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

@dkaravias dkaravias merged commit 50daf34 into master Oct 19, 2018
@dkaravias dkaravias deleted the add_rule_for_mockserver branch October 19, 2018 10:10
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.

None yet

2 participants