From c64f3bf06e029c1d40127b4a5805c1d2095ea1ae Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Thu, 4 Jul 2019 17:50:51 -0500 Subject: [PATCH] Add DoNotRunOnTravis annotation --- cameraview/build.gradle | 16 ++++++++++------ .../cameraview/DoNotRunOnTravis.java | 5 +++++ .../engine/CameraIntegration1Test.java | 3 ++- .../engine/CameraIntegration2Test.java | 3 ++- 4 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 cameraview/src/androidTest/java/com/otaliastudios/cameraview/DoNotRunOnTravis.java diff --git a/cameraview/build.gradle b/cameraview/build.gradle index 13617d89..866266d5 100644 --- a/cameraview/build.gradle +++ b/cameraview/build.gradle @@ -8,6 +8,8 @@ group = 'com.otaliastudios' //region android dependencies +def travis = System.getenv("TRAVIS") + android { compileSdkVersion rootProject.ext.compileSdkVersion // buildToolsVersion rootProject.ext.buildToolsVersion @@ -18,6 +20,9 @@ android { versionCode 1 versionName project.version testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + if (travis) { + testInstrumentationRunnerArgument "notAnnotation", "com.otaliastudios.cameraview.DoNotRunOnTravis" + } } buildTypes { @@ -34,13 +39,12 @@ android { dependencies { testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-core:2.28.2' + testImplementation 'org.mockito:mockito-inline:2.28.2' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test:rules:1.2.0' androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'com.google.dexmaker:dexmaker:1.2' - androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:1.2' + androidTestImplementation 'org.mockito:mockito-android:2.28.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' api 'androidx.exifinterface:exifinterface:1.0.0' @@ -90,7 +94,6 @@ install { def bintrayUser def bintrayKey -def travis = System.getenv("TRAVIS") if (travis) { bintrayUser = System.getenv("BINTRAY_USER") bintrayKey = System.getenv("BINTRAY_KEY") @@ -215,8 +218,9 @@ task mergedCoverageReport(type: JacocoReport) { ] if (travis) { // Since this is not testable on the emulator... - classFilter.add('com.otaliastudios.cameraview.engine.Camera1Engine') - classFilter.add('com.otaliastudios.cameraview.engine.Camera2Engine') + classFilter.add('com.otaliastudios.cameraview.engine.CameraEngine.*') + classFilter.add('com.otaliastudios.cameraview.engine.Camera1Engine.*') + classFilter.add('com.otaliastudios.cameraview.engine.Camera2Engine.*') } classDirectories = fileTree(dir: classDir, excludes: classFilter); diff --git a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/DoNotRunOnTravis.java b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/DoNotRunOnTravis.java new file mode 100644 index 00000000..03860330 --- /dev/null +++ b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/DoNotRunOnTravis.java @@ -0,0 +1,5 @@ +package com.otaliastudios.cameraview; + +public @interface DoNotRunOnTravis { + String because() default ""; +} diff --git a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/CameraIntegration1Test.java b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/CameraIntegration1Test.java index 746e76e0..33eeea02 100644 --- a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/CameraIntegration1Test.java +++ b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/CameraIntegration1Test.java @@ -1,5 +1,6 @@ package com.otaliastudios.cameraview.engine; +import com.otaliastudios.cameraview.DoNotRunOnTravis; import com.otaliastudios.cameraview.controls.Engine; import org.junit.Ignore; @@ -18,7 +19,7 @@ import androidx.test.filters.LargeTest; */ @RunWith(AndroidJUnit4.class) @LargeTest -@Ignore("These do work but fail on CI emulators, due to bugs in the Camera1 emulated devices.") +@DoNotRunOnTravis(because = "These do work but fail on CI emulators, due to bugs in the Camera1 emulated devices.") public class CameraIntegration1Test extends CameraIntegrationTest { @NonNull diff --git a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/CameraIntegration2Test.java b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/CameraIntegration2Test.java index b67bb84d..54cf6014 100644 --- a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/CameraIntegration2Test.java +++ b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/CameraIntegration2Test.java @@ -1,5 +1,6 @@ package com.otaliastudios.cameraview.engine; +import com.otaliastudios.cameraview.DoNotRunOnTravis; import com.otaliastudios.cameraview.controls.Engine; import org.junit.Ignore; @@ -17,7 +18,7 @@ import androidx.test.filters.LargeTest; */ @RunWith(AndroidJUnit4.class) @LargeTest -@Ignore("These do work but fail on CI emulators.") +@DoNotRunOnTravis(because = "These do work but fail on CI emulators.") public class CameraIntegration2Test extends CameraIntegrationTest { @NonNull