JakeWharton / hugo

Annotation-triggered method call logging for your debug builds.
Apache License 2.0
7.92k stars 798 forks source link

@DebugLog annotated method causes Android unit tests to crash/fail #117

Open alecplumb opened 8 years ago

alecplumb commented 8 years ago

I've created the following example test: https://github.com/alecplumb/hugo/blob/demo_test_failure/hugo-example/src/test/java/com/example/hugo/HugoActivityTest.java

Running the test results in the following error:

java.lang.RuntimeException: Method myLooper in android.os.Looper not mocked. See http://g.co/androidstudio/not-mocked for details.

    at android.os.Looper.myLooper(Looper.java)
    at hugo.weaving.internal.Hugo.enterMethod(Hugo.java:77)
    at hugo.weaving.internal.Hugo.ajc$inlineAccessMethod$hugo_weaving_internal_Hugo$hugo_weaving_internal_Hugo$enterMethod(Hugo.java:1)
    at hugo.weaving.internal.Hugo.logAndExecute(Hugo.java:44)
    at com.example.hugo.HugoActivity.fibonacci(HugoActivity.java:39)
    at com.example.hugo.HugoActivityTest.testFibonacci(HugoActivityTest.java:9)
    ...
dEn13L commented 8 years ago

And I can't find method Hugo.setEnabled, just

Hugo.aspectOf()
Hugo.hasAspect()
droidster commented 6 years ago

@alecplumb @dEn13L Were you able to fix this?

AlexMisiulia commented 5 years ago

Hello from 2019. For now, you can just add this to gradle file:

android {
    testOptions {
        unitTests.returnDefaultValues = true
    }
}