KasperskyLab / Kaspresso

Android UI test framework
https://kasperskylab.github.io/Kaspresso/
Apache License 2.0
1.81k stars 154 forks source link

Kaspresso rewrite original stack on internal espresso errors #639

Closed VladislavSumin closed 3 months ago

VladislavSumin commented 7 months ago

Describe the bug When we receive an error inside the espresso library, kaspresso replaces the stacktrace with its own, and the original stacktrace is lost. It happens here - https://github.com/KasperskyLab/Kaspresso/blob/1fcb27f37ff3138b6fbdcc2fcc81e72e193e65d1/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/failure/FailureLoggingProviderImpl.kt#L96. Example of espresso internal error - https://github.com/KakaoCup/Kakao/issues/60

Instead of the original stack we get this:

StackTrace ``` java.lang.NullPointerException at dalvik.system.VMStack.getThreadStackTrace(Native Method) at java.lang.Thread.getStackTrace(Thread.java:1736) at com.kaspersky.kaspresso.failure.FailureLoggingProviderImpl.describedWith(FailureLoggingProviderImpl.kt:96) at com.kaspersky.kaspresso.failure.FailureLoggingProviderImpl.logDescriptionAndThrow(FailureLoggingProviderImpl.kt:69) at com.kaspersky.kaspresso.failure.LoggingFailureHandler.logDescriptionAndThrow(Unknown Source:2) at com.kaspersky.kaspresso.failure.LoggingFailureHandler.handle(LoggingFailureHandler.kt:21) at androidx.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:8) at androidx.test.espresso.ViewInteraction.desugaredPerform(ViewInteraction.java:11) at androidx.test.espresso.ViewInteraction.perform(ViewInteraction.java:8) at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor$interceptPerform$1.invoke(KakaoViewInterceptor.kt:46) at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor$interceptPerform$1.invoke(KakaoViewInterceptor.kt:44) at com.kaspersky.kaspresso.autoscroll.AutoScrollProviderImpl.withAutoScroll(AutoScrollProviderImpl.kt:31) at com.kaspersky.kaspresso.interceptors.behavior.impl.autoscroll.AutoScrollViewBehaviorInterceptor.withAutoScroll(Unknown Source:12) at com.kaspersky.kaspresso.interceptors.behavior.impl.autoscroll.AutoScrollViewBehaviorInterceptor.intercept(AutoScrollViewBehaviorInterceptor.kt:26) at com.kaspersky.kaspresso.interceptors.behavior.impl.autoscroll.AutoScrollViewBehaviorInterceptor.intercept(AutoScrollViewBehaviorInterceptor.kt:14) at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor$interceptPerform$2$1.invoke(KakaoViewInterceptor.kt:51) at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor$interceptPerform$2$1.invoke(KakaoViewInterceptor.kt:51) at com.kaspersky.kaspresso.systemsafety.SystemDialogSafetyProviderImpl.passSystemDialogs(SystemDialogSafetyProviderImpl.kt:60) at com.kaspersky.kaspresso.interceptors.behavior.impl.systemsafety.SystemDialogSafetyViewBehaviorInterceptor.passSystemDialogs(Unknown Source:7) at com.kaspersky.kaspresso.interceptors.behavior.impl.systemsafety.SystemDialogSafetyViewBehaviorInterceptor.intercept(SystemDialogSafetyViewBehaviorInterceptor.kt:30) at com.kaspersky.kaspresso.interceptors.behavior.impl.systemsafety.SystemDialogSafetyViewBehaviorInterceptor.intercept(SystemDialogSafetyViewBehaviorInterceptor.kt:16) at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor$interceptPerform$2$1.invoke(KakaoViewInterceptor.kt:51) at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor$interceptPerform$2$1.invoke(KakaoViewInterceptor.kt:51) at com.kaspersky.kaspresso.flakysafety.algorithm.FlakySafetyAlgorithm.invokeFlakySafely(FlakySafetyAlgorithm.kt:32) at com.kaspersky.kaspresso.flakysafety.algorithm.FlakySafetyAlgorithm.invokeFlakySafely$default(FlakySafetyAlgorithm.kt:22) at com.kaspersky.kaspresso.flakysafety.FlakySafetyProviderSimpleImpl.flakySafely(FlakySafetyProviderSimpleImpl.kt:27) at com.kaspersky.kaspresso.interceptors.behavior.impl.flakysafety.FlakySafeViewBehaviorInterceptor.flakySafely(Unknown Source:7) at com.kaspersky.kaspresso.interceptors.behavior.impl.flakysafety.FlakySafeViewBehaviorInterceptor.intercept(FlakySafeViewBehaviorInterceptor.kt:26) at com.kaspersky.kaspresso.interceptors.behavior.impl.flakysafety.FlakySafeViewBehaviorInterceptor.intercept(FlakySafeViewBehaviorInterceptor.kt:14) at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor$interceptPerform$2$1.invoke(KakaoViewInterceptor.kt:51) at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor$interceptPerform$2$1.invoke(KakaoViewInterceptor.kt:51) at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor.interceptPerform(KakaoViewInterceptor.kt:53) at com.kaspersky.kaspresso.interceptors.tolibrary.KakaoLibraryInjector$injectKaspressoInKakao$1$1$2.invoke(KakaoLibraryInjector.kt:57) at com.kaspersky.kaspresso.interceptors.tolibrary.KakaoLibraryInjector$injectKaspressoInKakao$1$1$2.invoke(KakaoLibraryInjector.kt:57) at io.github.kakaocup.kakao.delegate.Delegate$DefaultImpls.interceptOnPerform(Delegate.kt:68) at io.github.kakaocup.kakao.delegate.Delegate$DefaultImpls.interceptPerform$intercept$3(Delegate.kt:44) at io.github.kakaocup.kakao.delegate.Delegate$DefaultImpls.interceptPerform(Delegate.kt:49) at io.github.kakaocup.kakao.delegate.ViewInteractionDelegate.interceptPerform(ViewInteractionDelegate.kt:21) at io.github.kakaocup.kakao.delegate.ViewInteractionDelegate.interceptPerform(ViewInteractionDelegate.kt:21) at io.github.kakaocup.kakao.delegate.ViewInteractionDelegate.perform(ViewInteractionDelegate.kt:41) at io.github.kakaocup.kakao.recycler.RecyclerActions$DefaultImpls.scrollToEnd(RecyclerActions.kt:30) at .CustomRecyclerView.scrollToEnd(...) at .SomeTest$someTest$1$2$4$2$1.invoke(...) ```

Expected behavior The original error is attached as suppressedExceptions

Screenshots NONE

Desktop (please complete the following information): ANY

Smartphone (please complete the following information): ANY

Additional context Add any other context about the problem here.

Nikitae57 commented 3 months ago

Closed too soon