用于仪器测试的Firebase测试实验室错误

时间:2017-11-12 22:29:26

标签: java android firebase uiautomator firebase-test-lab

我是Android开发的新手。我正在使用UIAutomator和Android Studio 3.0中的另一个应用程序创建黑盒测试。我想在Google Firebase Testlab中运行它。我收到一些警告/错误,我不知道如何处理。 这是project/app/src/androidTest/java/com.firebaseapp.test_test.test/ExampleInstrumentedTest.java中的代码:

//This code doesn't wait for elements to appear, doesnt do error handling/reporting, etc.
//Its just a proof of concept of running in firebase test lab, which it doesnt
package com.firebaseapp.test_test.test;

import android.content.Context;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiSelector;
import android.support.test.uiautomator.Until;

import org.junit.Test;
import org.junit.runner.RunWith;

import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static org.junit.Assert.assertEquals;

/**
 * Instrumented test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
    @Test
    public void useAppContext() throws Exception {
        // Context of the app under test.
        Context appContext = InstrumentationRegistry.getTargetContext();
        UiDevice mDevice = UiDevice.getInstance(getInstrumentation()); //assign device

        assertEquals("com.firebaseapp.test_test.test", appContext.getPackageName()); //idk, this was here by default
        Intent intent = appContext.getPackageManager().getLaunchIntentForPackage("com.testapp.android"); //look for testapp
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); //if testapp is currently running, close it
        appContext.startActivity(intent); //start testapp
        mDevice.wait(Until.hasObject(By.pkg("com.testapp.android")), 30); //make sure testappstarted correctly

        mDevice.findObject(new UiSelector().resourceId("com.testapp.android:id/log_in")).clickAndWaitForNewWindow(); //Click log in button
        mDevice.findObject(new UiSelector().resourceId("com.testapp.android:id/login_user")).setText("username"); //fill in username
        mDevice.findObject(new UiSelector().resourceId("com.testapp.android:id/pass")).setText("password"); //Fill in password
        mDevice.findObject(new UiSelector().resourceId("com.testapp.android:id/next_btn")).clickAndWaitForNewWindow(); //Click sign in, wait
    }

}

以下是project/app/src/main/AndroidManifest.xml中的清单XML:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.firebaseapp.root_registrar.rootregistrar">
    <uses-sdk
        tools:overrideLibrary="android.support.test.uiautomator.v18"/> //idk if this is the right version, just found it online
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" />

</manifest>

以下是我的错误(排除所有正常日志/警告,超出此帖子的限制: Errors

我尝试单独构建仪器化测试APK。我尝试构建它进行调试。我尝试将其构建以供发布。我尝试用签名来构建它。我甚至在测试实验室中运行它之前会遇到各种错误,说测试APK没有有效的签名,或者测试APK不包含清单文件中指定的测试运行器类。我真的对所有这些应用程序签名,清单文件和测试实验室的随机看似错误感到困惑(尽管在Nexus 5 Android 7.0上的Android Studio中运行测试的ExampleInstrumentation.java)

我想我的问题很广泛。我应该怎么做才能使这个黑盒子测试apk在我的testapp的APK在Firebase测试实验室作为仪器测试运行?

0 个答案:

没有答案