Prevent DebugLog logs messages when running code under JUnit.#30
Open
VictorAlbertos wants to merge 1 commit intoandroid10:masterfrom
VictorAlbertos:master
Open
Prevent DebugLog logs messages when running code under JUnit.#30VictorAlbertos wants to merge 1 commit intoandroid10:masterfrom VictorAlbertos:master
VictorAlbertos wants to merge 1 commit intoandroid10:masterfrom
VictorAlbertos:master
Conversation
| */ | ||
| public void log(String tag, String message) { | ||
| Log.d(tag, message); | ||
| if (!runningJUnit()) |
There was a problem hiding this comment.
I believe it would be better to just catch all Exceptions as it won't slow down execution of unit tests as much as checking the stack trace. Moreover, this implementation is tied to JUnit. What if we are just running our code on desktop?
Author
There was a problem hiding this comment.
I tried to catch the exception but I think this kind of exception is not possible to catch.
There was a problem hiding this comment.
Should just work:
try {
Log.d(tag, message);
} catch (Exception e) {
// Ignore
}
Author
There was a problem hiding this comment.
It didn't work when I tried it. It was my first approach, actually. But you can try it and let me know, maybe I missed something I don't know ;)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi.
I've been getting the next exception when running a JUnit test which calls methods annotated with
@RxLogObservableI've been able to fix the error by adding the next configuration test to gradle:
android { testOptions { unitTests.returnDefaultValues = true } }This pull request tries to fix that. I've been able to compile the project and run successfully the unit tests of "frodo-runtime" module. But it seems that DebugLog class isn't covered by any of them (probably not need for that until now).
Also, I don't know how can I test this new functionality from the android sample app. I couldn't connect the "frodo-plugin" gradle locally with the sample app. Indeed, I don't even know if that's possible (I have a very limited knowledge about gradle plugins).