Closed britolucaspatrick closed 3 weeks ago
Hi @britolucaspatrick, thanks for opening this issue.
Could you please give us the exact dependencies and test dependencies you're using for your tests? Are those Unit Tests running in the JVM (which I guess is the case, as you're using Robolectric)? What are you trying to achieve by initialising the Datadog SDK in the tests?
Hi @xgouchet , Thank you for your contact.
implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.9.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.databinding:viewbinding:7.1.2' implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation 'com.google.code.gson:gson:2.8.8' implementation "com.airbnb.android:lottie:6.1.0" implementation "io.reactivex.rxjava2:rxjava:2.2.6" implementation "io.reactivex.rxjava2:rxandroid:2.1.1" implementation 'com.android.volley:volley:1.2.1' implementation 'net.danlew:android.joda:2.9.9.4' implementation 'com.google.guava:guava:31.1-jre'
implementation "com.datadoghq:dd-sdk-android-okhttp:2.3.0"
implementation "com.datadoghq:dd-sdk-android-rum:2.3.0"
implementation "com.datadoghq:dd-sdk-android-trace:2.3.0"
implementation "com.datadoghq:dd-sdk-android-logs:2.3.0"
testImplementation 'androidx.test.ext:junit-ktx:1.1.5'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:3.12.4'
testImplementation 'org.mockito:mockito-inline:3.12.4'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.9.1'
testImplementation 'org.robolectric:robolectric:4.10.2'
testImplementation "io.mockk:mockk-android:1.13.5"
testImplementation "io.mockk:mockk-agent:1.13.5"
testImplementation 'androidx.test:core-ktx:1.5.0'
testImplementation 'androidx.arch.core:core-testing:2.2.0'
I managed to solve the problems with mocks
Describe the bug
running datadog using unit tests the error is thrown
roboeletric 4.10.2 mockito 3.12.4
even attempts to mock the Datadog class don't work
Reproduction steps
create a unit test and call the initialize function, observe in the logcat
Logcat logs
Exception in thread "datadog_shutdown" java.lang.IllegalArgumentException: Receiver not registered: com.datadog.android.core.internal.system.BroadcastReceiverSystemInfoProvider@6eaf1125
Expected behavior
don't throw any exceptions,
and work with mockk
Affected SDK versions
2.14.0
Latest working SDK version
2.14.0
Did you confirm if the latest SDK version fixes the bug?
Yes
Kotlin / Java version
1.8.0
Gradle / AGP version
7.3.3
Other dependencies versions
No response
Device Information
No response
Other relevant information
No response