diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index f5a4e0d..01a355a 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -36,4 +36,10 @@ jobs: - name: Build and test run: | - ./example/android/gradlew testDebugUnitTest -p ./example/android/ \ No newline at end of file + ./example/android/gradlew testDebugUnitTest jacocoTestReport -p ./example/android/ + + - name: Upload coverage report to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + files: android/build/reports/jacocoTestReport.xml + token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index d6114ce..2b073c4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.3.1' + classpath "com.android.tools.build:gradle:8.8.2" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -23,6 +23,7 @@ allprojects { apply plugin: 'com.android.library' apply plugin: 'kotlin-android' +apply plugin: 'jacoco' android { compileSdk 35 @@ -71,8 +72,42 @@ android { ndkVersion '27.0.12077973' } +tasks.register('jacocoTestReport', JacocoReport) { + dependsOn 'testDebugUnitTest' + + reports { + xml.required = true + xml.outputLocation.set(file("$project.projectDir/build/reports/jacocoTestReport.xml")) + html.required = false + csv.required = false + } + + def fileFilter = [ + '**/R.class', + '**/R$*.class', + '**/BuildConfig.*', + '**/Manifest*.*', + '**/CalendarApi*', + '**/Calendar.class', + '**/Calendar$Companion.class', + '**/Event*.class', + '**/Account*.class', + ] // ignore pigeon generated files + def mainSrc = "${project.projectDir}/src/main/kotlin/sncf/connect/tech/eventide/" + + sourceDirectories.setFrom(files(mainSrc)) + classDirectories.setFrom(files("${buildDir}/intermediates/runtime_library_classes_dir/debug/sncf/connect/tech/eventide/").asFileTree.matching { + exclude fileFilter + }) + executionData.setFrom(files("${buildDir}/jacoco/testDebugUnitTest.exec")) +} + +tasks.withType(Test).configureEach { + useJUnitPlatform() + finalizedBy jacocoTestReport +} + dependencies { - implementation("androidx.activity:activity-ktx:1.10.0") + implementation("androidx.activity:activity-ktx:1.10.1") implementation("androidx.fragment:fragment-ktx:1.8.6") } - diff --git a/example/android/app/build.gradle.kts b/example/android/app/build.gradle.kts index 964904f..b2d0ccf 100644 --- a/example/android/app/build.gradle.kts +++ b/example/android/app/build.gradle.kts @@ -3,6 +3,11 @@ plugins { id("kotlin-android") // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id("dev.flutter.flutter-gradle-plugin") + id("jacoco") +} + +jacoco { + toolVersion = "0.8.8" } android { diff --git a/example/pubspec.lock b/example/pubspec.lock index 9ecfbfd..a004b48 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -80,14 +80,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" - file: - dependency: transitive - description: - name: file - sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 - url: "https://pub.dev" - source: hosted - version: "7.0.1" flutter: dependency: "direct main" description: flutter @@ -101,11 +93,6 @@ packages: url: "https://pub.dev" source: hosted version: "8.1.6" - flutter_driver: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" flutter_lints: dependency: "direct dev" description: @@ -119,11 +106,6 @@ packages: description: flutter source: sdk version: "0.0.0" - fuchsia_remote_debug_protocol: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" http: dependency: transitive description: @@ -140,11 +122,6 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.2" - integration_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" leak_tracker: dependency: transitive description: @@ -217,14 +194,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" - platform: - dependency: transitive - description: - name: platform - sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" - url: "https://pub.dev" - source: hosted - version: "3.1.6" plugin_platform_interface: dependency: transitive description: @@ -233,14 +202,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" - process: - dependency: transitive - description: - name: process - sha256: "107d8be718f120bbba9dcd1e95e3bd325b1b4a4f07db64154635ba03f2567a0d" - url: "https://pub.dev" - source: hosted - version: "5.0.3" provider: dependency: transitive description: @@ -294,14 +255,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.4.1" - sync_http: - dependency: transitive - description: - name: sync_http - sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" - url: "https://pub.dev" - source: hosted - version: "0.3.1" term_glyph: dependency: transitive description: @@ -367,14 +320,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" - webdriver: - dependency: transitive - description: - name: webdriver - sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8" - url: "https://pub.dev" - source: hosted - version: "3.0.4" sdks: dart: ">=3.7.0-0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index d9e5bbd..cb4382f 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -22,8 +22,6 @@ dependencies: timezone: ^0.10.0 dev_dependencies: - integration_test: - sdk: flutter flutter_test: sdk: flutter flutter_lints: ^4.0.0 diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart deleted file mode 100644 index 4896183..0000000 --- a/example/test/widget_test.dart +++ /dev/null @@ -1,27 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility in the flutter_test package. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'package:eventide_example/main.dart'; - -void main() { - testWidgets('Verify Platform version', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); - - // Verify that platform version is retrieved. - expect( - find.byWidgetPredicate( - (Widget widget) => - widget is Text && widget.data!.startsWith('Running on:'), - ), - findsOneWidget, - ); - }); -}