# #android #junit #gitlab #gitlab-ci #cicd
Вопрос:
Я сгенерировал два этапа в Gitalb cicd pipline ,кроме того, я использую junit для тестирования некоторых функций в моем приложении my gitlab-ci.yml, как это :
image: vratislav/gitlab-ci-fastlane-android
stages:
- build
- test
before_script:
- export ANDROID_HOME="/sdk"
- export GRADLE_USER_HOME=$(pwd)/.gradle
- chmod x ./gradlew
cache:
key: ${CI_PROJECT_ID}
paths:
- .gradle/
build:
stage: build
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/apk/app-debug.apk
debugTests:
stage: test
script:
- ./gradlew -Pci --console=plain :gateway:testDebug
Этап сборки успешно пройден, но этап тестирования не запущен,более того, я получил вышеуказанную ошибку в конвейере :
> Task :gateway:preDebugUnitTestBuild UP-TO-DATE
> Task :gateway:javaPreCompileDebugUnitTest
> Task :gateway:compileDebugUnitTestJavaWithJavac
> Task :gateway:compileDebugUnitTestJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':gateway:compileDebugUnitTestJavaWithJavac'.
> Could not resolve all files for configuration ':gateway:debugUnitTestCompileClasspath'.
> Failed to transform bcprov-jdk15on-1.68.jar (org.bouncycastle:bcprov-jdk15on:1.68) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for JetifyTransform: /home/mohsenq/builds/HRPaURW5/0/mohsen/hayatgateway/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk15on/1.68/46a080368d38b428d237a59458f9bc915222894d/bcprov-jdk15on-1.68.jar.
> Failed to transform '/home/mohsenq/builds/HRPaURW5/0/mohsen/hayatgateway/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk15on/1.68/46a080368d38b428d237a59458f9bc915222894d/bcprov-jdk15on-1.68.jar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 59. (Run with --stacktrace for more details.)
Suggestions:
- Check out existing issues at https://issuetracker.google.com/issues?q=componentid:460323amp;s=modified_time:desc, it's possible that this issue has already been filed there.
- If this issue has not been filed, please report it at https://issuetracker.google.com/issues/new?component=460323 (run with --stacktrace and provide a stack trace if possible).
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2m 14s
16 actionable tasks: 16 executed
ERROR: Job failed: exit status 1
И, наконец, я должен упомянуть свою сборку. :
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "ir.fanap.hayat.gateway"
minSdkVersion 24
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude("META-INF/*.kotlin_module")
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta4"
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
implementation group: 'org.eclipse.paho', name: 'org.eclipse.paho.client.mqttv3', version: '1.2.5'
implementation group: 'org.springframework.android', name: 'spring-android-rest-template', version: '1.0.1.RELEASE'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.12.2'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.12.2'
implementation group: 'org.mapstruct', name: 'mapstruct', version: '1.4.2.Final'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'org.nanohttpd:nanohttpd:2.3.1'
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.9.1'
implementation group: 'com.j256.ormlite', name: 'ormlite-core', version: '5.3'
implementation group: 'com.j256.ormlite', name: 'ormlite-android', version: '5.3'
implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '3.9'
// test dependency
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
testImplementation group: 'org.robolectric', name: 'robolectric', version: '4.6.1'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}