小编Mao*_*dad的帖子

在app中运行仪器测试并等待结果

我正在开发一种QA自动化解决方案,可以在Android上记录/回放QA测试.关键业务要求是在回放录制的测试时不依赖于连接的PC.为此,我试图在没有连接PC的情况下运行仪器测试.(具体来说,是Appium UiAutomator2测试).

我目前的方法是尝试从我的应用程序以编程方式运行测试.如果我通常从连接的PC运行测试,我会使用该命令adb shell am instrument -w.我尝试从我的应用程序访问ADB Shell并运行am instrument -w,但这会产生错误,我错过了INTERACT_ACROSS_USERS_FULL权限.

为了解决这个问题,我尝试使用startInstrumentation运行测试.这成功地开始了测试.但是,测试立即崩溃.经过进一步调查,我将崩溃追踪到NPE:测试试图检索InstrumentationRegistry.getInstrumentation.getUiAutomation(0),但是返回null.

如何以编程方式运行测试并授予其访问所需的UiAutomation实例的权限?

这就是我开始测试的方式:

public void runTest() {
    final String pm = getPackageName().replaceFirst(".test$", "");
    final InstrumentationInfo info = getInstrumentationInfo(pm);
    if (info != null) {

        final ComponentName cn = new ComponentName(info.packageName,
                info.name);

        Bundle arguments = new Bundle();
        arguments.putString("class", "io.testim.appiumwrapper.test.AppiumUiAutomator2Server");
        //cn = {io.extension.test/android.support.test.runner.AndroidJUnitRunner}
        startInstrumentation(cn, null, arguments);

    } 
}
Run Code Online (Sandbox Code Playgroud)

android android-testing appium android-instrumentation appium-android

20
推荐指数
1
解决办法
788
查看次数

IndexOutOfBoundsException添加Garmin FIT RecordMesg自定义字段

我的应用生成一个.Fit文件.

它适用于标准API.但是当我尝试添加自定义字段时,它被忽略或无法被客户端解析.

我正在使用FIT SDK 2.0.

fit::DeveloperDataIdMesg DPSdevIdMesg;
    uint8_t appId[] = {
      0x67, 0x72, 0x69, 0x73, 0x68, 0x61, 0x20, 0x68, 0x61, 0x20, 0x6d, 0x65, 0x6c, 0x65, 0x6b, 0x68
    };
    for (int appIdx = 0; appIdx < 16; ++appIdx) {
        DPSdevIdMesg.SetApplicationId( appIdx, appId[appIdx] );
    }

    DPSdevIdMesg.SetDeveloperDataIndex(0);
    encode.Write(DPSdevIdMesg);

fit::FieldDescriptionMesg DPSfieldDescMesg;
    DPSfieldDescMesg.SetDeveloperDataIndex(0);
    DPSfieldDescMesg.SetFieldDefinitionNumber(0);
    DPSfieldDescMesg.SetFitBaseTypeId(FIT_FIT_BASE_TYPE_FLOAT64);
    FIT_WSTRING DPSname = L"DPS";
    DPSfieldDescMesg.SetFieldName(0,DPSname );
    DPSfieldDescMesg.SetUnits( 0, L"m" );
    encode.Write(DPSfieldDescMesg);

for (size_t k = 0; k < intervals_size; k++) {
  std::vector<commons::timestamped<commons::gps_point>> gps_points =  interval_report.gps_points;
            size_t gpsPointsSize = gps_points.size();

            for …
Run Code Online (Sandbox Code Playgroud)

garmin

6
推荐指数
0
解决办法
160
查看次数

如何在 Android kotlin、Moshi 和 Retrofit 中使用动态键解析嵌套 JSON?

如何在 Android kotlin、Moshi 和 Retrofit 中使用NESTED动态键解析嵌套 JSON ?

我从alpha-vantage得到这个 JSON 。

格式示例:

{
    "Meta Data": {
        "1. Information": "Intraday (15min) open, high, low, close prices and volume",
        "2. Symbol": "AAME",
        "3. Last Refreshed": "2019-11-18 16:00:00",
        "4. Interval": "15min",
        "5. Output Size": "Compact",
        "6. Time Zone": "US/Eastern"
     },
    "Time Series (15min)": {//Dynamic - > Time Series (5min) / Time Series (30min)
        "2019-11-18 16:00:00": {//Dynamic
            "1. open": "1.6700",
            "2. high": "1.6700",
            "3. low": "1.5700",
            "4. close": "1.5700",
            "5. …
Run Code Online (Sandbox Code Playgroud)

android kotlin kotlin-android-extensions moshi retrofit2

6
推荐指数
1
解决办法
2994
查看次数

什么是Android M +可以拥有的最大并发Ble连接数

我的应用程序需要同时连接9个Ble设备.在本文和任何其他资源中,它写的android 4.4+只能连接到7个设备.M或N版本有什么新东西吗?谢谢.

bluetooth-lowenergy android-ble

4
推荐指数
2
解决办法
3049
查看次数