老李推荐:第8章2节《MonkeyRunner源码剖析》MonkeyRunner启动运行过程-解析处理命令行参数 2
2016-01-05 16:44
381 查看
我们这一节会先去分析下monkeyrunner是如何对参数进行处理的,我们跳转到MonkeyRunnerOptions这个类里面的processOptions这个方法:93 public static MonkeyRunnerOptions processOptions(String[] args) 94 { 95 int index = 0; 96 97 String hostname = DEFAULT_MONKEY_SERVER_ADDRESS; 98 File scriptFile = null; 99 int port = DEFAULT_MONKEY_PORT;100 String backend = "adb";101 Level logLevel = Level.SEVERE;102103 ImmutableList.Builder<File> pluginListBuilder = ImmutableList.builder();104 ImmutableList.Builder<String> argumentBuilder = ImmutableList.builder();105 while (index < args.length) {106 String argument = args[(index++)];107108 if ("-s".equals(argument)) {109 if (index == args.length) {110 printUsage("Missing Server after -s");111 return null;112 }113 hostname = args[(index++)];114 }115 else if ("-p".equals(argument))116 {117 if (index == args.length) {118 printUsage("Missing Server port after -p");119 return null;120 }121 port = Integer.parseInt(args[(index++)]);122 }123 else if ("-v".equals(argument))124 {125 if (index == args.length) {126 printUsage("Missing Log Level after -v");127 return null;128 }129130 logLevel = Level.parse(args[(index++)]);131 } else if ("-be".equals(argument))132 {133 if (index == args.length) {134 printUsage("Missing backend name after -be");135 return null;136 }137 backend = args[(index++)];138 } else if ("-plugin".equals(argument))139 {140 if (index == args.length) {141 printUsage("Missing plugin path after -plugin");142 return null;143 }144 File plugin = new File(args[(index++)]);145 if (!plugin.exists()) {146 printUsage("Plugin file doesn't exist");147 return null;148 }149150 if (!plugin.canRead()) {151 printUsage("Can't read plugin file");152 return null;153 }154155 pluginListBuilder.add(plugin);156 } else if (!"-u".equals(argument))157 {158 if ((argument.startsWith("-")) && (scriptFile == null))159 {160161162 printUsage("Unrecognized argument: " + argument + ".");163 return null;164 }165 if (scriptFile == null)166 {167168 scriptFile = new File(argument);169 if (!scriptFile.exists()) {170 printUsage("Can't open specified script file");171 return null;172 }173 if (!scriptFile.canRead()) {174 printUsage("Can't open specified script file");175 return null;176 }177 } else {178 argumentBuilder.add(argument);179 }180 }181 }182183 return new MonkeyRunnerOptions(hostname,port,scriptFile,backend,logLevel,pluginListBuilder.build(),argumentBuilder.build());184 }185 }代码8-2-2 MonkeyRunnerOptions - processOptions
相关文章推荐
- 老李性能测试分享
- 你想不到:咖啡馆里上工具课
- 移动端自动化测试开课了
- 老李分享:什么是好战略
- 性能调优案例分享:Mysql的cpu过高
- 性能测试分享:性能测试工具开发的案例分享(上)
- 性能测试分享:性能测试工具开发的案例分享(下)
- 性能测试培训:批量执行Jmeter脚本之ant调用 2
- 性能测试培训:分布式测试之jmeter1
- 老李案例分享:MAT分析应用程序服务出现内存溢出过程1
- 老李案例分享:MAT分析应用程序服务出现内存溢出过程2
- 老李案例分享:定位JAVA内存溢出 1
- 老李案例分享:定位JAVA内存溢出 2
- 性能测试培训: 建立压力模型
- 老李分享:你知道有哪些持续集成工具
- 老李分享知识:性能测试之TPS和吞吐率
- 老李分享知识:性能测试之吞吐量
- 性能测试培训:分析内训泄露的案例
- 自动化测试培训:qtp脚本获取获取汇率数据
- 性能测试培训:sql server性能测试分析局部变量的性能影响1