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

Remove dependency on android.text.TextUtils #23

Merged
merged 2 commits into from
Jul 5, 2016

Conversation

cahlbin
Copy link
Contributor

@cahlbin cahlbin commented Jul 5, 2016

If ReLinker is run in an environment where the Android APIs are provided by roboeletrict, android.text.TextUtils.isEmpty() would throw a roboteletric "Stub!" RuntimeException.

This changeset removes the dependency on android.text.TextUtils.

@xiphirx
Copy link
Collaborator

xiphirx commented Jul 5, 2016

Thanks for the PR. Quick question: how are you loading native libraries with robolectric? I understand the point of this pull request, but I'm unsure if ReLinker would work at all with robolectric...

@cahlbin
Copy link
Contributor Author

cahlbin commented Jul 5, 2016

Good point, and actually I think I confused myself in terms of
Roboeletric. I now realise I wasn't even running the particular test
with Roboelectic (but rather with PowerMock), thus the
android.text.TextUtils throwing the "Stub!" exception.

But, I think the PR still is valuable as it essentially removes the
need to stub android.text.TextUtils (via either roboeletric,
PowerMock, or something else).

And just to clarify my use case. Say I have class A.java and it's
corresponding integration test, ATest.java. Class A is further
dependent on class B (a concrete class, not an interface), which
unconditionally makes use of ReLinker to load native libraries. Also
note that ATest is an integration tests (i.e. B will not be stubbed /
mocked). Though one could always argue that ATest could be run with a
mock of B, but for various reasons, that was not an option at the
time.

So back to the PR changeset, minimizing the number Android APIs
used by ReLinker will reduce the number of Android APIs that have to
be stubbed in various test run environments.

Another use case is a test case for class A that should verify how A
fails in case native library loading fails.

@xiphirx xiphirx merged commit bf47ce8 into KeepSafe:master Jul 5, 2016
@xiphirx
Copy link
Collaborator

xiphirx commented Jul 5, 2016

Sure makes sense. Less dependencies on Android the better. Merged, thanks!

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.

2 participants