avito-android

Форк
0
1
package com.avito.instrumentation
2

3
import com.avito.test.gradle.TestProjectGenerator
4
import com.avito.test.gradle.ciRun
5
import com.avito.test.gradle.module.AndroidAppModule
6
import com.avito.test.gradle.plugin.plugins
7
import org.junit.jupiter.api.Test
8
import org.junit.jupiter.api.io.TempDir
9
import java.io.File
10

11
internal class LocalEnvironmentTest {
12

13
    @Test
14
    fun `run local instrumentation by name - ok`(@TempDir projectDir: File) {
15
        val moduleName = "app"
16

17
        TestProjectGenerator(
18
            plugins = plugins {
19
                id("com.avito.android.gradle-logger")
20
            },
21
            modules = listOf(
22
                AndroidAppModule(
23
                    moduleName,
24
                    plugins = plugins {
25
                        id(instrumentationPluginId)
26
                    },
27
                    imports = listOf(
28
                        "import com.avito.instrumentation.reservation.request.Device",
29
                        "import com.avito.instrumentation.configuration.report.ReportConfig",
30
                    ),
31
                    buildGradleExtra = instrumentationConfigurationWithCloudEmulator(),
32
                    useKts = true
33
                )
34
            ),
35
        ).generateIn(projectDir)
36

37
        ciRun(
38
            projectDir,
39
            ":$moduleName:instrumentationNonCloudLocal",
40
            dryRun = true
41
        ).assertThat()
42
            .run {
43
                tasksShouldBeTriggered(":$moduleName:instrumentationNonCloudLocal")
44
            }
45
    }
46

47
    private fun instrumentationConfigurationWithCloudEmulator(): String = """
48
    |instrumentation {
49
    |    outputDir.set(project.file("outputs"))
50
    |    report.set(ReportConfig.NoOp)
51
    |
52
    |    instrumentationParams = mapOf(
53
    |        "jobSlug" to "FunctionalTests"
54
    |    )
55
    |
56
    |    configurations {
57
    |
58
    |        register("nonCloud") {
59
    |            instrumentationParams = mapOf(
60
    |                "deviceName" to "api22"
61
    |            )
62
    |
63
    |            targets {
64
    |                register("api22") {
65
    |                    deviceName = "api22"
66
    |
67
    |                    scheduling {
68
    |                        quota {
69
    |                            minimumSuccessCount = 1
70
    |                        }
71
    |
72
    |                        staticDevicesReservation {
73
    |                            device = Device.LocalEmulator.device(27)
74
    |                            count = 1
75
    |                        }
76
    |                    }
77
    |                }
78
    |            }
79
    |        }
80
    |
81
    |        register("cloud") {
82
    |            instrumentationParams = mapOf(
83
    |                "deviceName" to "api29"
84
    |            )
85
    |
86
    |            targets {
87
    |                register("api29") {
88
    |                    deviceName = "api29"
89
    |
90
    |                    scheduling {
91
    |                        quota {
92
    |                            minimumSuccessCount = 1
93
    |                        }
94
    |
95
    |                        staticDevicesReservation {
96
    |                            device = Device.CloudEmulator(
97
    |                                name = "api29",
98
    |                                api = 29,
99
    |                                model = "Android_SDK_built_for_x86_64",
100
    |                                image = "avitotech/android-emulator-29:915c1f20be",
101
    |                            )
102
    |                            count = 1
103
    |                        }
104
    |                    }
105
    |                }
106
    |            }
107
    |        }
108
    |    }
109
    |}
110
    |
111
    |android {
112
    |    defaultConfig {
113
    |        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
114
    |        testInstrumentationRunnerArguments(mapOf("planSlug" to "AvitoAndroid"))
115
    |    }
116
    |}
117
    |""".trimMargin()
118
}
119

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.