当前位置: 首页>>代码示例>>Java>>正文


Java InstrumentationRegistry.getArguments方法代码示例

本文整理汇总了Java中android.support.test.InstrumentationRegistry.getArguments方法的典型用法代码示例。如果您正苦于以下问题:Java InstrumentationRegistry.getArguments方法的具体用法?Java InstrumentationRegistry.getArguments怎么用?Java InstrumentationRegistry.getArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.test.InstrumentationRegistry的用法示例。


在下文中一共展示了InstrumentationRegistry.getArguments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MacacaTestRunner

import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
@Test
public void MacacaTestRunner() throws Exception {
    Bundle args = InstrumentationRegistry.getArguments();

    int port = 9001;
    if (args.containsKey("port")) {
        port = Integer.parseInt(args.getString("port"));
    }

    UIAutomatorWDServer server = UIAutomatorWDServer.getInstance(port);
    Utils.print("UIAutomatorWD->" + "http://localhost:" + server.getListeningPort() + "<-UIAutomatorWD");

    if (args.containsKey("permissionPattern")) {
        JSONArray permissionPatterns = JSON.parseArray(args.getString("permissionPattern"));
        skipPermission(permissionPatterns, 15);
    }

    while (true) {
        SystemClock.sleep(1000);
    }
}
 
开发者ID:macacajs,项目名称:UIAutomatorWD,代码行数:22,代码来源:UIAutomatorWD.java

示例2: getTestConfig

import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
private TestRunnerConfig getTestConfig() throws AutomationRunnerException {
    TestRunnerConfig testConfig = new TestRunnerConfig();
    Bundle arguments = InstrumentationRegistry.getArguments();
    String testConfigName = "default";
    if (arguments != null && arguments.containsKey("config")) {
        testConfigName = arguments.getString("config");
    }
    if (arguments != null && arguments.containsKey("coverage") && Boolean.parseBoolean(arguments.getString("coverage"))) {
        testConfigName = "coverage";
    }

    testConfig = (TestRunnerConfig) new Gson().fromJson(AssetUtils.ReadAsset(getContext(), "config" + File.separator + testConfigName + File.separator + "testsetup.json"), TestRunnerConfig.class);

    if (arguments != null && arguments.containsKey("screenshots")) {
        testConfig.Screenshots = Boolean.parseBoolean(arguments.getString("screenshots"));
    }

    if (arguments != null && arguments.containsKey("includeskipped")) {
        testConfig.IncludeSkipped = Boolean.parseBoolean(arguments.getString("includeskipped"));
    }

    if (arguments != null && arguments.containsKey("writetestreport")) {
        testConfig.WriteTestReport = Boolean.parseBoolean(arguments.getString("writetestreport"));
    }

    if(arguments != null && arguments.containsKey("detailederrors")) {
        testConfig.DetailedErrors = Boolean.parseBoolean(arguments.getString("detailederrors"));
    }

    if(testConfig.CoverageReport) {
        if (arguments != null && arguments.containsKey("coverageFile")) {
            testConfig.CoverageFile = arguments.getString("coverageFile");
        }
    }

    if (arguments != null && arguments.containsKey("tags") && arguments.getString("tags") != null) {
        testConfig.FilterType = "tag";
        testConfig.FilterBy = arguments.getString("tags").toLowerCase(Locale.getDefault());
    }
    if (arguments != null && arguments.containsKey("tag") && arguments.getString("tag") != null) {
        testConfig.FilterType = "tag";
        testConfig.FilterBy = arguments.getString("tag").toLowerCase(Locale.getDefault());
    } else if (arguments != null && arguments.containsKey("file") && arguments.getString("file") != null) {
        testConfig.FilterType = "file";
        testConfig.FilterBy = arguments.getString("file").toLowerCase(Locale.getDefault());
    } else if (arguments != null && arguments.containsKey("scenario") && arguments.getString("scenario") != null) {
        testConfig.FilterType = "scenario";
        testConfig.FilterBy = arguments.getString("scenario").toLowerCase(Locale.getDefault());
    }
    else if(arguments != null && arguments.containsKey("runmode") && arguments.getString("runmode") != null) {
        testConfig.FilterType = arguments.getString("runmode").toLowerCase(Locale.getDefault());
        if(testConfig.FilterType.equals("previously-failed") && !testConfig.WriteTestReport) {
            throw new AutomationRunnerException("Previously failed tests only was requested, but report logging was disabled in the given testsetup.json.", null);
        }
    }

    return testConfig;
}
 
开发者ID:andrewjc,项目名称:kheera-testrunner-android,代码行数:59,代码来源:FeatureFileExecutorFactory.java


注:本文中的android.support.test.InstrumentationRegistry.getArguments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。