如何做集成测试Android上的新摇篮构建系统?摇篮、如何做、测试、系统

2023-09-05 06:03:09 作者:怎么骄傲怎么活

我们的Andr​​oid应用程序的需要自动测试,我们的小组正在使用Robotium来处理我们。这是单元测试没有问题,但我们还编写了一套端至端集成测试的后端服务器锻炼不仅在客户端也是如此。我有一些测试,做到这一点,但如果可能的话,我想单独打破他们从单元测试,使我们的持续集成版本不要求现场服务器是为了完成运行。

Our Android app needs automated testing, and our group is using Robotium to handle that for us. This is no problem for unit tests, but we're also writing a set of end-to-end integration tests to exercise not only the client by the back-end servers as well. I've got some tests that do this, but if possible, I'd like to break them out separately from the unit tests so that our continuous integration builds don't require a live server to be running in order to complete.

我们正在用崭新的摇篮构建系统。我想知道如果我可以做类似测试,只有香料或子项目依赖于父APK让它走。我试图使这项工作有一个单独的项目共使用Robotium指令测试源少调试APK,但没有奏效。也许是因为我是在真实的硬件,而不是一个仿真器。我有运气不佳的仿真器,即使安装了硬件加速。

We're using the shiny new Gradle build system. I'm wondering if I could do something like a test-only flavor or a subproject that depends on the parent APK to make it go. I tried making this work with a separate project altogether using the Robotium instructions for testing a source-less debug APK, but it didn't work. Maybe because I was on real hardware and not an emulator. I've had poor luck with the emulator, even with the hardware acceleration installed.

任何意见,或者我应该只是认为我的呼吸和翻滚着我的构建需要集成服务器时生成正在发生可用?

Any advice, or should I just hold my breath and roll with my builds requiring the integration server to be available when builds are happening?

推荐答案

据他们 Maven的说明所有你需要做的就是添加 robotium独奏作为一个编译依赖。

According to their Maven instructions all you need to do is add robotium-solo as a compile dependency.

repositories {
    mavenCentral()
}

dependencies {
    instrumentTestCompile 'com.jayway.android.robotium:robotium-solo:4.2'
}

这将确保您的 robotium-solo.jar 文件中的类路径中。然后定义你的测试在的src / instrumentTest 目录,然后运行摇篮构建。其是否正常工作?

This will ensure you have the robotium-solo.jar file in your classpath. Then define your tests in the src/instrumentTest directory and run gradle build. See if that works?

我会帮助在那里我可以,因为我们从行家转化为摇篮大约一年前。

I'll help where I can, as we converted from maven to gradle about a year ago.

*编辑OP想测试从摇篮构建单独运行,因此该解决方案是指定设置,像这样一个自定义源:

*EDIT OP wanted the tests to run separately from a gradle build, so the solution is to specify a custom source set like so:

sourceSets {
    integrationTest {
        // Gives you access to the compiled classes in your tests
        compileClasspath += main.output
        runtimeClasspath += main.output
    }
}

dependencies {
    integrationTestCompile 'com.jayway.android.robotium:robotium-solo:4.2'
}

// To run the tests: ./gradlew integrationTest
task integrationTest(type: Test) {
    testClassesDir = sourceSests.integrationTest.output.classesDir
    classpath = sourceSets.integrationTest.runtimeClasspath
}

注:我没有此计算机上安装了Android SDK。如果 main.output 不起作用尝试用 andriod.sourceSets.main.output ,看看是否可行。

Note: I don't have the android SDK installed on this computer. If main.output does not work try it with andriod.sourceSets.main.output and see if that works.

 
精彩推荐