@ParameterizedTest @CsvSource({ "滴滴,滴滴出行", "alibaba,阿里巴巴", "sougou,搜狗" }) public void 搜索股票(String searchInfo,String exceptName) { String name = searchpage.inputSearchInfo(searchInfo).getAll().get(0); assertThat(name,equalTo(exceptName)); } |
pdd xiaomi pdd |
@ParameterizedTest @CsvFileSource(resources = "/data/SearchTest.csv") void 选择(String keyword){ ArrayList<String> arrayList = searchpage.inputSearchInfo("xiaomi").addSelected(); } |
<dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-yaml</artifactId> <version>2.9.2</version> </dependency> |
ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); User user = mapper.readValue(yamlSource, User.class); |
public static GlobalConfig load(String path){ ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); try { GlobalConfig config = mapper.readValue(GlobalConfig.class.getResource(path), GlobalConfig.class); return config; } catch (IOException e) { e.printStackTrace(); return null; } } |
xqDemoConfig: username: 888 password: 666 testdata: 滴滴: 滴滴出行 alibaba: 阿里巴巴 sougou: 搜狗 |
@ParameterizedTest @MethodSource("YamlData") public void 搜索股票2(String searchInfo,String exceptName) { String name = searchpage.inputSearchInfo(searchInfo).getAll().get(0); assertThat(name,equalTo(exceptName)); } static Stream<Arguments> YamlData(){ GlobalConfig config =GlobalConfig.load("/data/globalConfig.yaml"); List<Arguments> list = new ArrayList<>(); Arguments arguments = null; for (String key : config.xqDemoConfig.testdata.keySet()) { Object value = config.xqDemoConfig.testdata.get(key); arguments = arguments(key, value); list.add(arguments); } return Stream.of(list.get(0),list.get(1),list.get(2)); } |
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) | Powered by Discuz! X3.2 |