0

我试图在 VSapp 中心配置我的测试用例,我的测试是用 appium 编写的。遵循以下步骤:

步骤 1#在我的项目根文件夹的 build.gradle 中添加了启用的 JCenter 存储库。build.gradle 文件如下

    buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

步骤 2#在 app 文件夹内的 build.gradle 文件中添加 androidTestCompile('com.microsoft.appcenter:appium-test-extension:1.0')

apply plugin: 'com.android.application'



android {
    compileSdkVersion 25
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.example.keya.myapplication"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestCompile('com.microsoft.appcenter:appium-test-extension:1.0')
    def appCenterSdkVersion = '1.1.0'
    compile "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
    compile "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"

    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'

    testCompile 'org.assertj:assertj-core:2.0.0'
    testCompile 'org.testng:testng:6.8.8'

    compile files('libs/apache-mime4j-0.6.jar')
    compile files('libs/commons-codec-1.10.jar')
    compile files('libs/commons-collections-3.2.1.jar')
    compile files('libs/commons-io-2.4.jar')
    compile files('libs/commons-exec-1.3.jar')
    compile files('libs/commons-lang3-3.4.jar')
    compile files('libs/commons-logging-1.1.3.jar')
    compile files('libs/commons-validator-1.4.1.jar')
    compile files('libs/gson-2.3.1.jar')
    compile files('libs/guava-18.0.jar')
    compile files('libs/httpclient-4.4.1.jar')
    compile files('libs/httpcore-4.4.1.jar')
    compile files('libs/httpmime-4.4.1.jar')
    compile 'com.android.support:support-annotations:25.0.1'
    compile group: 'com.beust', name: 'jcommander', version: '1.27'




    testCompile 'info.cukes:cucumber-java:1.2.5'
    testCompile 'info.cukes:cucumber-junit:1.2.5'
    testCompile 'info.cukes:cucumber-picocontainer:1.2.2'




    compile 'com.android.support:support-v4:25.0.1'
}

apply plugin: 'maven'

task createPom {
    pom {
        withXml {
            def dependenciesNode = asNode().appendNode('dependencies')

            //Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
            configurations.testCompile.allDependencies.each {
                def dependencyNode = dependenciesNode.appendNode('dependency')
                dependencyNode.appendNode('groupId', it.group)
                dependencyNode.appendNode('artifactId', it.name)
                        dependencyNode.appendNode('version', it.version)
            }

            def profilesNode = asNode().appendNode('profiles')
            profilesNode.append(new XmlParser().parse('https://raw.githubusercontent.com/Microsoft/AppCenter-Test-Appium-Java-Extensions/master/gradleuploadprofilesnippet.xml'))
        }
    }.writeTo("pom.xml")}

在这一步中,一切都成功构建成功但是当我尝试导入以下库时

import com.microsoft.appcenter.appium.Factory;
import com.microsoft.appcenter.appium.EnhancedAndroidDriver;

应用导入失败

Step3#我也尝试使用 mvn 导入库 --> 这一步没有用。

应用程序显示无法解析符号消息有人可以建议我解决方案吗?

4

1 回答 1

0

找到了问题的解决方案,只需将 jar 作为库添加到构建路径中,并且工作正常

于 2017-12-23T16:07:56.170 回答