亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-99久久99久久-99久久99久久精品国产

您的位置:軟件測(cè)試 > 開(kāi)源軟件測(cè)試 > 開(kāi)源單元測(cè)試工具 > junit
自定義注解過(guò)濾JUnit測(cè)試類
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2013/10/28 15:59:00 ] 推薦標(biāo)簽:

  PS:編寫(xiě)測(cè)試類時(shí),一般是在基類中讀取配置文件,并為某些成員賦值。而在MyBuilder中傳入基類的成員變量作為過(guò)濾條件是不行的,因?yàn)镸yBuilder的運(yùn)行還在測(cè)試基類之前,此時(shí)基類的任何變量都為null。在MyBuilder中自定義過(guò)濾條件的變量,必須在MyBuilder中從配置文件里實(shí)時(shí)讀取。由于基類也需要加載配置文件,為避免重復(fù)加載,建議將讀配置類實(shí)現(xiàn)為單例模式:
public class MyConfiguration {
private volatile static MyConfiguration uniqueInstance;
private Properties propertie;
private FileInputStream inputFile;
private MyConfiguration() {
propertie = new Properties();
}
private MyConfiguration(String configFile) {
propertie = new Properties();
try {
inputFile = new FileInputStream(configFile);
propertie.load(inputFile);
inputFile.close();
} catch (FileNotFoundException ex) {
System.out
.println("load properties file failed! maybe file not exist!");
ex.printStackTrace();
} catch (IOException ex) {
System.out.println("load properties file failed!");
ex.printStackTrace();
}
}
/**
* @return unique instance
*/
public static MyConfiguration getInstance(String configFile) {
if (uniqueInstance == null) {
synchronized (MyConfiguration.class) {
if (uniqueInstance == null) {
uniqueInstance = new MyConfiguration(configFile);
}
}
}
return uniqueInstance;
}
public String getValue(String key) {
if (propertie.containsKey(key)) {
String value = propertie.getProperty(key);
return value;
} else
return "";
}
}
  相應(yīng)的,MyBuilder可修改為:
public class MyBuilder extends RunnerBuilder {
@Override
public Runner runnerForClass(Class<?> testClass) throws Throwable {
String properties = "src/test/resources/test.properties";
MyConfiguration conf = MyConfiguration.getInstance(properties);
if (testClass.getAnnotation(MyIgnore.class) != null) {
if (!"true".equals(conf.getValue("runFlag")))
return new IgnoredClassRunner(testClass);
}
return new BlockJUnit4ClassRunner(testClass);
}
}

上一頁(yè)123下一頁(yè)
軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd
主站蜘蛛池模板: 欧美国产成人免费观看永久视频 | 欧美极品第一页 | 伦理影院在线观看 | 麻豆国内精品久久久久久 | 欧美性猛交ⅹxxx乱大交免费 | vod国产成人精品视频 | 欧美一区二区三区视视频 | 成人免费男女视频网站慢动作 | 亚洲三级在线视频 | 黄黄的网站 | 国产免费一级精品视频 | 波多野结衣中文字幕在线 | 色视频线观看在线播放 | 精品伊人久久久 | 日韩大片免费观看 | 伊人干 | 无遮羞禁黄动漫在线观看 | 2021天堂在线亚洲精品专区 | 亚洲欧美日韩中文字幕在线不卡 | 国产成人夜间影院在线观看 | 色综合天天综合 | 日本高清乱理论片 | 亚洲综合激情丁香六月 | 日日噜噜噜夜夜爽爽狠狠 | 国产精品莉莉欧美自在线线 | 国产精品xxxav免费视频 | 好男人社区成人影院在线观看 | 国产精品xxxxbbbb18 | 日韩激情小视频 | 亚洲一级毛片在线观 | bl高h肉边走边做 | 精品免费国产一区二区三区 | 亚洲欧美久久婷婷爱综合一区天堂 | 欧美成人一区二区三区 | 国产成人女人在线视频观看 | 国产黄色影院 | 日本中文字幕一区二区 | a级特黄毛片免费观看 | 99re5精品视频在线观看 | 日本一区二区三区久久精品 | 亚洲黄色免费在线观看 |