首页 > 其他 > 详细

白盒测试实战——NITIAN Word

时间:2014-04-13 05:30:01      阅读:622      评论:0      收藏:0      [点我收藏+]

最近,我在编写一款自娱自乐的单词对比记忆的软件NITIAN WORD,这里选取它的一部分逻辑,利用白盒方法进行测试,算是理论联系实际吧。


主要逻辑代码:

		String wordsArray[] = new String[Global.input_words_ceiling];
		
		NTDictionary dict = new NTDictionary();
	
		while(!endFlag) {
			System.out.println("----------------------------------------------------------");
			System.out.println("please input a group of English words");
			System.out.println("words separated by a space, and end up with the key Enter");
			System.out.println("and enter q to quit");
			
			sc = new Scanner(System.in);
			String st = sc.nextLine().trim(); // wipe out the head and the tall space
			
			if(st.equals("q")) {
				endFlag = true;
				System.out.println("you have exit normally");
			} else if(st.equals("")) {
				System.out.println("the input should not be empty");
			} else {
				
				//use regular expression to make sure that the string only consists of English characters
				Pattern pattern = Pattern.compile("^[A-Za-z\\s]+$");
				Matcher matcher = pattern.matcher(st);
				boolean isAllEngFlag = matcher.matches();
				
				if(isAllEngFlag == true) {
				
					wordsArray = st.split("\\s+");  // wipe out more spaces and get each word
					
					int isExist = dict.judgeExistence(wordsArray); //judge whether there is the identical entry
					
					if(isExist == 0) {
						dict.collectWords(wordsArray);//if not exist, collect the entry	
						System.out.println("yeah, SUCCESS");
					} else {
						System.out.println("there is already entry");
						System.out.println("the line num is-----> " + isExist);
					}
				} else {
					System.out.println("your input shoud only be composed of English characters");
				}
			}

程序流程图:

bubuko.com,布布扣

bubuko.com,布布扣

白盒测试之语句覆盖:

bubuko.com,布布扣

白盒测试之判定覆盖:

bubuko.com,布布扣

测试情况:

bubuko.com,布布扣

总结:

这里语句覆盖和判定覆盖所用的最少测试用例一模一样,这是因为只要执行到一个可执行语句,就意味着结束,所以有多少个执行语句,就有多少个测试用例,从而达到语句覆盖的目的。而在判定覆盖中,只要用例能全部执行到可执行代码实际上就涵盖了所有的分支,同样一个用例只能执行一个可执行语句。所以二者的用例一模一样,证明完毕。



白盒测试实战——NITIAN Word,布布扣,bubuko.com

白盒测试实战——NITIAN Word

原文:http://blog.csdn.net/bluecloudmatrix/article/details/23497447

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!