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

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

  PS:編寫測試類時(shí),一般是在基類中讀取配置文件,并為某些成員賦值。而在MyBuilder中傳入基類的成員變量作為過濾條件是不行的,因?yàn)镸yBuilder的運(yùn)行還在測試基類之前,此時(shí)基類的任何變量都為null。在MyBuilder中自定義過濾條件的變量,必須在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);
}
}

上一頁123下一頁
軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd
主站蜘蛛池模板: 国产精品久久久精品视频 | 亚洲国产精品久久久久久网站 | 免费簧网站永久在线播放国产 | 亚洲理论a中文字幕在线 | 色啊色| 日韩毛片免费在线观看 | 日本人真淫视频一区二区三区 | 日韩一区二区在线观看 | 久久久久久午夜精品 | 亚洲w码欧洲s码免费 | 成年午夜性爽快免费视频不卡 | 在线观看中文字幕 | 亚洲小视频在线 | 免费高清在线观看a网站 | 欧美一级高清片欧美国产欧美 | 日本成片免费高清 | 飘花国产午夜精品不卡 | 一级特黄aa毛片免费观看 | 午夜视频福利在线观看 | 日韩欧美在线观看成人 | 国亚洲欧美日韩精品 | 欧美日韩一本大道香蕉欧美 | 一本色道久久综合亚洲精品高清 | 精品国产不卡一区二区三区 | 久久99精品久久久久久国产越南 | 最近更新中文字幕第一页 | 成人免费黄色大片 | 国产精品天干天干在线观看澳门 | 黑丝视频网站 | 久久网站免费 | 午夜性爽快免费视频播放 | 免费大片黄在线现看国语 | 国产成人禁片免费观看视频 | 亚洲国产精品v在线播放 | 日韩在线视频精品 | 欧美日韩亚洲区久久综合 | 制服第一页| 日本xxxxx黄区免费看动漫 | 越南一级毛片免费 | 亚洲国产高清在线精品一区 | 欧美高清视频手机在在线 |