Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUM-5525 Add the integration tests for the SdkCore APIs #2145

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ espresso = "3.5.1"
assertJ = "3.18.1"
elmyr = "1.3.1"
mockitoKotlin = "5.1.0"
mockitoAndroid = "5.12.0"
kover = "0.7.6"
kspTesting = "1.5.0"

Expand Down Expand Up @@ -177,6 +178,7 @@ elmyrInject = { module = "com.github.xgouchet.Elmyr:inject", version.ref = "elmy
elmyrJUnit4 = { module = "com.github.xgouchet.Elmyr:junit4", version.ref = "elmyr" }
elmyrJUnit5 = { module = "com.github.xgouchet.Elmyr:junit5", version.ref = "elmyr" }
elmyrJVM = { module = "com.github.xgouchet.Elmyr:jvm", version.ref = "elmyr" }
mockitoAndroid = { module = "org.mockito:mockito-android", version.ref = "mockitoAndroid" }
mockitoKotlin = { module = "org.mockito.kotlin:mockito-kotlin", version.ref = "mockitoKotlin" }
kotlinReflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
kover = { module = "org.jetbrains.kotlinx:kover-gradle-plugin", version.ref = "kover" }
Expand Down
68 changes: 52 additions & 16 deletions reliability/core-it/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
* Copyright 2016-Present Datadog, Inc.
*/

import com.datadog.gradle.config.AndroidConfig
import com.datadog.gradle.config.androidLibraryConfig
import com.datadog.gradle.config.dependencyUpdateConfig
import com.datadog.gradle.config.java17
import com.datadog.gradle.config.javadocConfig
import com.datadog.gradle.config.junitConfig
import com.datadog.gradle.config.kotlinConfig
Expand All @@ -26,10 +28,43 @@ plugins {

android {
namespace = "com.datadog.android.core.integration"
defaultConfig {
minSdk = AndroidConfig.MIN_SDK
multiDexEnabled = true
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

compileOptions {
java17()
}

packaging {
resources {
excludes += listOf(
"META-INF/jvm.kotlin_module",
"META-INF/LICENSE.md",
"META-INF/LICENSE-notice.md"
)
}
}

sourceSets.named("test") {
// Required because AGP doesn't support kotlin test fixtures :/
java.srcDir("${project.rootDir.path}/dd-sdk-android-core/src/testFixtures/kotlin")
buildTypes {
getByName("release") {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
testProguardFile("test-proguard-rules.pro")
}
getByName("debug") {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
testProguardFile("test-proguard-rules.pro")
}
Comment on lines +51 to +67
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Why do you need a release build, and why minify both release and debug ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to test these in the same conditions as a normal app. We did the same for integration tests. Not sure is the best approach but I think it is better.

}
}

Expand All @@ -38,25 +73,26 @@ dependencies {
implementation(libs.kotlin)

// Testing
testImplementation(project(":tools:unit")) {
androidTestImplementation(project(":tools:unit")) {
attributes {
attribute(
com.android.build.api.attributes.ProductFlavorAttr.of("platform"),
objects.named("jvm")
objects.named("art")
)
}
}
testImplementation(testFixtures(project(":dd-sdk-android-core")))
testImplementation(libs.bundles.jUnit5)
testImplementation(libs.bundles.testTools)
testImplementation(libs.okHttp)
testImplementation(libs.gson)
unmock(libs.robolectric)
}

unMock {
keepStartingWith("android.os")
keepStartingWith("org.json")
androidTestImplementation(project(":reliability:stub-feature"))
androidTestImplementation(libs.assertJ)
androidTestImplementation(libs.mockitoAndroid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot see any usages of that. Is it really needed?

androidTestImplementation(libs.bundles.integrationTests)
androidTestImplementation(libs.elmyrJVM)
androidTestImplementation(libs.okHttp)
androidTestImplementation(libs.okHttpMock)
androidTestImplementation(libs.gson)
if (project.hasProperty(com.datadog.gradle.Properties.USE_API21_JAVA_BACKPORT)) {
// this is needed to make AssertJ working on APIs <24
androidTestImplementation(project(":tools:javabackport"))
}
}

androidLibraryConfig()
Expand Down
7 changes: 7 additions & 0 deletions reliability/core-it/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Needed to make sure we don't remove any test code
-dontshrink
#-dontoptimize
#-keepattributes *Annotation*

-dontwarn kotlin.Experimental$Level
-dontwarn kotlin.Experimental
Loading