내용으로 건너뛰기
LinDol's 실험실
사용자 도구
로그인
사이트 도구
검색
도구
문서 보기
이전 판
역링크
최근 바뀜
미디어 관리자
사이트맵
로그인
>
최근 바뀜
미디어 관리자
사이트맵
추적:
robolectric
이 문서는 읽기 전용입니다. 원본을 볼 수는 있지만 바꿀 수는 없습니다. 문제가 있다고 생각하면 관리자에게 문의하세요.
====== Setup ====== Add dependency to build.gradle in your app module <code Groovy> testImplementation 'org.robolectric:robolectric:4.3' testImplementation 'androidx.test:core:1.0.0' </code> ===== Why robolectric needs to use jdk9 from Q ===== Robolectric 이 AOSP framework build 에 기반해서 만들어지는데, Anroid Q 부터 java build toolchain이 java9로 변경된 관계로 jdk9를 쓸 수 밖에 없다고 함. 관련 링크: https://github.com/robolectric/robolectric/issues/5258 ====== Troubleshooting ====== Android studio 4.0에서 OpenJdk 11 (or 9이상)으로 Robolectric Unit test 실행시 아래의 에러가 날 경우 <code Bash> WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.robolectric.util.ReflectionHelpers$6 (file:/Users/lindol/.gradle/caches/modules-2/files-2.1/org.robolectric/shadowapi/4.3/81dfcf4a45b623b7744e46358d01c7ce054d0fff/shadowapi-4.3.jar) to method java.lang.ClassLoader.getPackage(java.lang.String) WARNING: Please consider reporting this to the maintainers of org.robolectric.util.ReflectionHelpers$6 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release [Robolectric] com.example.unittest.MainActivityTest.testSimpleLoad: sdk=28; resources=BINARY Downloading from maven Downloading: org/robolectric/android-all/Q-robolectric-5415296/android-all-Q-robolectric-5415296.pom from repository sonatype at https://oss.sonatype.org/content/groups/public/ Error transferring file: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext) [WARNING] Unable to get resource 'org.robolectric:android-all:pom:Q-robolectric-5415296' from repository sonatype (https://oss.sonatype.org/content/groups/public/): Error transferring file: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext) </code> 해결 방법: Robolectric 4.4 로 버전 올리기 ([[https://github.com/robolectric/robolectric/issues/5456|4.4 버전에서 수정됨]]) <code Groovy> testImplementation 'org.robolectric:robolectric:4.4' </code> ====== References ====== * [[http://robolectric.org|Robolectric]] - official website * [[https://developer.android.com/training/testing/set-up-project|Set up project for AndroidX Test]] * [[https://github.com/robolectric/robolectric/blob/master/robolectric/src/test/java/org/robolectric/shadows/ShadowTelephonyManagerTest.java|ShadowTelephonyManagerTest.java]] * [[http://robolectric.org/extending/|Shadows]] * [[https://meetup.toast.com/posts/187|[Android] Unit Testing Framework - Robolectric]] * [[https://www.codexpedia.com/android/robolectric-unit-test-sample-code-for-android/|Robolectric Unit Test Sample Code for Android]] * [[http://robolectric.org/blog/2019/06/04/paused-looper/|Improving Robolectric's Looper simulation]] * [[https://developer.android.com/reference/androidx/test/core/app/ActivityScenario|ActivityScenario]]
robolectric.txt
· 마지막으로 수정됨: 2020/09/12 17:45 저자
lindol
문서 도구
문서 보기
이전 판
역링크
맨 위로