Skip to content

Commit

Permalink
fix(android): add a simple sample of com.android.test + fix samples
Browse files Browse the repository at this point in the history
  • Loading branch information
Malinskiy committed Nov 15, 2023
1 parent a61225d commit 41af499
Show file tree
Hide file tree
Showing 81 changed files with 99 additions and 1,610 deletions.
27 changes: 27 additions & 0 deletions .idea/runConfigurations/android_test_gradle_plugin.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal class BillingReporter(
}

usageTracker.trackEvent(Event.Devices(bills.size))
val result = executionReport.summary.pools.map { it.failed.size == 0 }.reduce { acc, b -> acc && b }
val result = executionReport.summary.pools.map { it.failed.isEmpty() }.reduceOrNull { acc, b -> acc && b } ?: true
val flakiness = executionReport.summary.pools.sumOf { it.rawDurationMillis - it.durationMillis / 1000 }
val durationSeconds = ((Instant.now().toEpochMilli() - defaultStart.toEpochMilli()) / 1000)
usageTracker.trackEvent(Event.Executed(seconds = bills.sumOf { it.duration } / 1000,
Expand Down
2 changes: 1 addition & 1 deletion sample/android-app/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.malinskiy.marathon.config.vendor.android.TestParserConfiguration
plugins {
id("com.android.application")
id("kotlin-android")
id("com.malinskiy.marathon") version "0.8.2-SNAPSHOT"
id("com.malinskiy.marathon") version "0.8.5-SNAPSHOT"
}

android {
Expand Down
1 change: 1 addition & 0 deletions sample/android-app/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ pluginManagement {
rootProject.name = "android-app"
rootProject.buildFileName = "build.gradle.kts"
include("app")
include("ui-tests")
43 changes: 43 additions & 0 deletions sample/android-app/ui-tests/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import com.malinskiy.marathon.config.vendor.android.TestParserConfiguration

plugins {
id("com.android.test")
id("kotlin-android")
id("com.malinskiy.marathon") version "0.8.5-SNAPSHOT"
}

android {
buildToolsVersion = "34.0.0"
compileSdk = 33

namespace = "com.example.ui_tests"

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
}

defaultConfig {
minSdk = 21
targetSdk = 33

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

targetProjectPath(":app")
}

dependencies {
implementation(TestLibraries.testRunner)
implementation(TestLibraries.extJunit)
implementation(TestLibraries.espressoCore)
}

marathon {
testParserConfiguration = TestParserConfiguration.RemoteTestParserConfiguration()
uncompletedTestRetryQuota = 3
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.example.ui_tests
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.example.app_impl.AppActivity
import com.example.MainActivity

import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -20,12 +20,12 @@ import org.junit.Rule
class ExampleInstrumentedTest {

@get:Rule
val androidScenarioRule = ActivityScenarioRule(AppActivity::class.java)
val androidScenarioRule = ActivityScenarioRule(MainActivity::class.java)

@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.ui_tests.test", appContext.packageName)
assertEquals("com.example", appContext.packageName)
}
}
}
2 changes: 1 addition & 1 deletion sample/android-library/library/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id("com.android.library")
id("kotlin-android")
id("com.malinskiy.marathon") version "0.8.2-SNAPSHOT"
id("com.malinskiy.marathon") version "0.8.5-SNAPSHOT"
}

android {
Expand Down
15 changes: 0 additions & 15 deletions sample/android-test/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion sample/android-test/app_api/.gitignore

This file was deleted.

40 changes: 0 additions & 40 deletions sample/android-test/app_api/build.gradle.kts

This file was deleted.

31 changes: 0 additions & 31 deletions sample/android-test/app_api/src/main/AndroidManifest.xml

This file was deleted.

This file was deleted.

Loading

0 comments on commit 41af499

Please sign in to comment.