Skip to content

Commit 54637f7

Browse files
committed
Added tests for Android project and aggregation plugin
1 parent d837e39 commit 54637f7

File tree

16 files changed

+277
-0
lines changed

16 files changed

+277
-0
lines changed

kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/SettingsPluginTests.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,14 @@ internal class SettingsPluginTests {
8282
classCounter("tests.settings.subproject.SubprojectClass").assertAbsent()
8383
}
8484
}
85+
86+
@TemplateTest("settings-plugin-android", ["-Pkover", ":app:testDebugUnitTest", "koverXmlReport"])
87+
fun CheckerContext.testAndroid() {
88+
xmlReport {
89+
classCounter("kotlinx.kover.test.android.MainClass").assertCovered()
90+
classCounter("kotlinx.kover.test.android.DebugClass").assertFullyMissed()
91+
classCounter("kotlinx.kover.test.android.ReleaseClass").assertAbsent()
92+
classCounter("kotlinx.kover.test.android.LocalTests").assertAbsent()
93+
}
94+
}
8595
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
plugins {
6+
id ("com.android.application")
7+
id ("org.jetbrains.kotlin.android")
8+
}
9+
10+
android {
11+
namespace = "kotlinx.kover.test.android"
12+
compileSdk = 32
13+
14+
defaultConfig {
15+
applicationId = "kotlinx.kover.test.android"
16+
minSdk = 21
17+
targetSdk = 31
18+
versionCode = 1
19+
versionName = "1.0"
20+
21+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
22+
}
23+
24+
buildTypes {
25+
release {
26+
isMinifyEnabled = true
27+
}
28+
}
29+
compileOptions {
30+
sourceCompatibility = JavaVersion.VERSION_1_8
31+
targetCompatibility = JavaVersion.VERSION_1_8
32+
}
33+
kotlinOptions {
34+
jvmTarget = "1.8"
35+
}
36+
buildFeatures {
37+
viewBinding = true
38+
}
39+
}
40+
41+
dependencies {
42+
implementation("androidx.core:core-ktx:1.8.0")
43+
implementation("androidx.appcompat:appcompat:1.5.0")
44+
implementation("com.google.android.material:material:1.6.1")
45+
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
46+
testImplementation("junit:junit:4.13.2")
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package kotlinx.kover.test.android
6+
7+
object DebugClass {
8+
fun log(message: String) {
9+
println("DEBUG: $message")
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
4+
-->
5+
6+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
7+
8+
<application android:label="@string/app_name">
9+
<uses-library android:name="com.google.android.things" android:required="false" />
10+
11+
<activity android:name=".MainActivity"
12+
android:exported="true">
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN" />
15+
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
<!-- Make this the first activity that is displayed when the device boots. -->
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN" />
21+
22+
<category android:name="android.intent.category.HOME" />
23+
<category android:name="android.intent.category.DEFAULT" />
24+
</intent-filter>
25+
</activity>
26+
</application>
27+
28+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package kotlinx.kover.test.android
2+
3+
import android.os.Bundle
4+
import android.app.Activity
5+
6+
class MainActivity : Activity() {
7+
8+
override fun onCreate(savedInstanceState: Bundle?) {
9+
super.onCreate(savedInstanceState)
10+
setContentView(R.layout.activity_main)
11+
}
12+
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package kotlinx.kover.test.android
6+
7+
class MainClass {
8+
fun log(message: String) {
9+
println("DEBUG: $message")
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
4+
-->
5+
6+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
7+
xmlns:app="http://schemas.android.com/apk/res-auto"
8+
xmlns:tools="http://schemas.android.com/tools"
9+
android:layout_width="match_parent"
10+
android:layout_height="match_parent"
11+
tools:context=".MainActivity">
12+
13+
<TextView
14+
android:id="@+id/main_label"
15+
android:layout_width="wrap_content"
16+
android:layout_height="wrap_content"
17+
android:layout_marginStart="104dp"
18+
android:layout_marginTop="28dp"
19+
android:text="SERIALIZATION TEST"
20+
android:textSize="20sp"
21+
android:textStyle="bold"
22+
app:layout_constraintStart_toStartOf="parent"
23+
app:layout_constraintTop_toTopOf="parent" />
24+
25+
<EditText
26+
android:id="@+id/encoded_text"
27+
android:layout_width="373dp"
28+
android:layout_height="411dp"
29+
android:layout_marginStart="16dp"
30+
android:layout_marginTop="16dp"
31+
android:editable="false"
32+
android:ems="10"
33+
android:gravity="start|top"
34+
android:inputType="textMultiLine"
35+
android:textAlignment="viewStart"
36+
android:textSize="12sp"
37+
app:layout_constraintStart_toStartOf="parent"
38+
app:layout_constraintTop_toBottomOf="@+id/main_label" />
39+
40+
</androidx.constraintlayout.widget.ConstraintLayout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
4+
-->
5+
6+
<resources>
7+
<color name="purple_200">#FFBB86FC</color>
8+
<color name="purple_500">#FF6200EE</color>
9+
<color name="purple_700">#FF3700B3</color>
10+
<color name="teal_200">#FF03DAC5</color>
11+
<color name="teal_700">#FF018786</color>
12+
<color name="black">#FF000000</color>
13+
<color name="white">#FFFFFFFF</color>
14+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!--
2+
~ Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
-->
4+
5+
<resources>
6+
<string name="app_name">Android Test</string>
7+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!--
2+
~ Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
-->
4+
5+
<resources>
6+
7+
<style name="Theme.App" parent="android:Theme.Material.Light.DarkActionBar" />
8+
</resources>

0 commit comments

Comments
 (0)