狠狠干影院/欧美午夜电影在线观看/高黄文/国产精品一区二区在线观看完整版

黑盒測試實驗報告

| 瀏覽次數(shù):

  1 《 軟件測試技術(shù)

 》實驗報告

  2 實驗序號:

 04

  實驗項目名稱:黑盒測試

 3 一、實驗?zāi)康募耙?掌握用等價類、邊界值分析法、因果圖的方法設(shè)計測試用例 二、實驗設(shè)備(環(huán)境)及要求 實驗在計算機系的機房進行,安裝了 VC6.0,Java SDK,TurboC 等軟件,學生能采用 C 語言,C++,或 Java 語言進行編程。

 三、實驗內(nèi)容與步驟 任務(wù)一:傭金問題 問題描述如下:

 一酒水銷售公司指派銷售員銷售各種酒水。白酒賣 168 元/瓶,紅酒賣 120元/瓶,啤酒賣 5 元/瓶。白酒每月的供應(yīng)量為 5000 瓶,紅酒為 3000 瓶,啤酒為30000 瓶,各個銷售員每月至少要售出白酒 50 瓶,紅酒 30 瓶,啤酒 300 瓶。月末,每個銷售員上報他所在區(qū)域的銷售業(yè)績。這樣酒水銷售公司就知道了當月的銷售情況,并根據(jù)銷售額計算傭金提成如下:

 2 萬以下(含):4%; 2 萬(不含)~4.5 萬(含):1% 4.5 萬以上(不含):0.5% 這樣,傭金程序生成月份銷售報告,匯總售出的白酒、紅酒和啤酒總數(shù),銷售公司的總銷售額和各個銷售員的傭金。

 這個問題分為三個不同的部分:

 輸入數(shù)據(jù)部分,用來處理輸入數(shù)據(jù)的有效性; 銷售額計算部分; 傭金(提成)計算部分. 1、充分考慮輸入有效性校驗,編寫傭金問題的代碼; 2、按照等價類劃分的思想,設(shè)計等價類測試用例; 1)傭金問題中,首先分析輸入和輸出,注意分析傭金問題中給出和隱含的

 對輸入條件的要求:

 2)針對輸入進行等價類劃分,形成等價類列表,并為每一個等價類編號;

 3)從等價類劃分的表格中設(shè)計測試用例:為有效等價類設(shè)計測試用例,為每一個無效等價類至少設(shè)計一個測試用例 3、執(zhí)行測試,記錄發(fā)現(xiàn)的問題。

 任務(wù)二:下一天問題 1、對于 NextDate 問題,分析它的輸入限制;

 2、從輸入限制的邊界設(shè)計測試用例;

 3、執(zhí)行測試,記錄結(jié)果。

 任務(wù)三:自動售貨機問題 有一個處理單價為 5 角錢的飲料的自動售貨機軟件測試用例的設(shè)計。其規(guī)格說明如下:若投入 5 角錢或 1 元錢的硬幣,押下[橙汁]或[啤酒]的按鈕,則相應(yīng)的飲料酒送出來。若售貨機沒有零錢找,則一個顯示[零錢找完]的紅燈亮,這時再投入 1 元硬幣并押下按鈕后,飲料不送出來而且 1 元硬幣也退出來;若有零錢找,則顯示[零錢找完]的紅燈滅,在送出飲料的同時退還 5 角硬幣。

 1、分析這一段說明,列出原因和結(jié)果

 2、畫出因果圖。所有原因結(jié)點列在左邊,所有結(jié)果結(jié)點列在右邊。建立中間結(jié)點,表示處理的中間狀態(tài)。中間結(jié)點:

 1)投入 1 元硬幣且押下飲料按鈕

  2) 押下〖橙汁〗或〖啤酒〗的按鈕

  3) 應(yīng)當找 5 角零錢并且售貨機有零錢找

  4)錢已付清

 3、轉(zhuǎn)換成判定表

 4、在判定表中,把不可能出現(xiàn)的情況刪去。

 5、最后根據(jù)判定表中剩下的列作為確定測試用例的依據(jù),設(shè)計測試用例。

 6、實驗報告要求及記錄、格式 四、程序調(diào)試與結(jié)果 1、傭金問題

 1)劃分等價類并編號,下表等價類劃分的結(jié)果

 輸入等價類 有效等價類 無效等價類 白酒數(shù)量 ○1 在 50~5000 之間 ○2 在 0~49 之間 ○3 在 5000 以上不包括5000 紅酒數(shù)量 ○4 在 30~3000 之間 ○5 在 0~29 之間 ○6 在 3000 以上不包括3000

 啤酒數(shù)量 ○7 在 300~30000 之間 ○8 在 0~299 之間 ○9 在 30000 以上不包括30000 2)設(shè)計測試用例,以便覆蓋所有的有效等價類在表中列出了 3 個有效等價類,編號分別為①、○4 、○7 ,設(shè)計的測試用例如下:

 測試數(shù)據(jù) 期望結(jié)果 覆蓋的有效等價類

 (55,40,400)

 輸入有效 ①、○4 、○7

  3)為每一個無效等價類設(shè)計一個測試用例,設(shè)計結(jié)果如下:

 測試數(shù)據(jù) 期望結(jié)果 覆蓋的無效等價類 (30,40,400)

 輸入無效 ○2 (5500,40,400)

 輸入無效 ○3 (55,25,400)

 輸入無效 ○5

 (55,4000,400)

 輸入無效 ○6 (55,75,250)

 輸入無效 ○8 (55,75,33000)

 輸入無效 ○9

  4) 測試結(jié)果:所有測試都成功,且測試的覆蓋率為百分百

  2、NextDate 問題

 1)分析它的輸入限制

 NextDate 是一個有三個變量(月份、日期和年)的函數(shù)。函數(shù)返回輸入日期后面的那個日期。變量月份、日期和年都是整數(shù)值,并滿足以下條件:

 c1:1<=月份<=12 c2:1<=日期<=31 c3:1812<=年<=2012

 2)邊界值測試設(shè)計 編號 輸入 期望輸出 Year Month Day 001 1993 -1 15 Month 不在 1~12 中 002 1993 0 15 Month 不在 1~12 中 003 1993 1 15 1993 年 1 月 16 日 004 1993 11 15 1993 年 11 月 16 日

 005 1993 12 15 1993 年 12 月 16 日 006 1993 13 15 Month 不在 1~12 中

 007 1993 6 -1 Day 不在 1~31 中 008 1993 6 0 Day 不在 1~31 中 009 1993 6 1 1993 年 6 月 2 日 010 1993 6 15 1993 年 6 月 16 日 011 1993 6 29 1992 年 6 月 30 日 012 1993 6 30 1992 年 7 月 1 日 013 1993 6 31 Day 不在 1~30 中 014 1993 2 -1 Day 不在 1~29 中 015 1993 2 0 Day 不在 1~29 中 016 1993 2 1 1993 年 2 月 2 日 017 1993 2 15 1993 年 2 月 16 日 018 1992 2 28 1993 年 2 月 29 日 029 1993 2 28 1993 年 3 月 1 日 019 1992 2 29 1993 年 3 月 1 日 020 1993 2 29 平年 2 月沒有 29 號 021 1993 2 30 Day 不在 1~31 中 022 1993 2 31 Day 不在 1~31 中 023 1993 12 -1 Day 不在 1~31 中 024 1993 12 0 Day 不在 1~31 中 025 1993 12 1 1993 年 12 月 2 日 026 1993 12 30 1993 年 12 月 31 日 027 1993 12 31 1994 年 1 月 1 日 028 1993 12 32 Day 不在 1~31 中 030 1993 1 -1 Day 不在 1~31 中 031 1993 1 0 Day 不在 1~31 中 032 1993 1 1 1993 年 1 月 2 日 033 1993 1 30 1993 年 1 月 31 日

 034 1993 1 31 1993 年 2 月 1 日 035 1993 1 32 Day 不在 1~31 中 3)測試結(jié)果:所有測試都成功,且測試的覆蓋率為百分百

 3、自動售貨機問題 1)分析 自動售貨機中一共存在 5 個條件和 5 個結(jié)果:

 條件:C1、售貨機有零錢找

  C2、投入 1 元硬幣

  C3、投入 5 角硬幣

  C4、按下橙汁按鈕

  C5、按下啤酒按鈕 結(jié)果:E1、售貨機“零錢找完”燈亮

  E2、退還 1 元硬幣

  E3、退還 5 角硬幣

  E4、送出橙汁飲料

  E5、送出啤酒飲料 2)因果圖的分析結(jié)果

 有零錢選橙汁選啤酒投5角投1元紅燈亮出橙汁出啤酒找5角找1元EE選商品 錢付清VVVV應(yīng)該找零錢V能夠找零錢VV 4 )有效的條件組合構(gòu)成的判定表

 輸入 C1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 C2 1 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 C3 0 0 0 1 1 1 0 0 0 0 0 1 1 1 0 0 C4 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 C5 0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1

  結(jié)果 E1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 E2 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 E3 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 E4 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 E5 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 5)測試用例 編號 輸入值 狀態(tài) 期望值 001 (cola,1D)

 有零錢 Type Error 002 (OrangeJuice,1D)

 有零錢 送出橙汁,退 5 角 003 (Beer,1D)

 有零錢 送出啤酒,退 5 角 004 (cola,5C)

 有零錢 Type Error 005 (OrangeJuice,5C)

 有零錢 送出橙汁

 006 (Beer,5C)

 有零錢 送出啤酒 007 (OrangeJuice,4C)

 有零錢 Money Error 008 (Beer,4C)

 有零錢 Money Error 009 (cola,1D)

 無零錢 紅燈亮,退 1 元 010 (OrangeJuice,1D)

 無零錢 紅燈亮,退 1 元 011 (Beer,1D)

 無零錢 紅燈亮,退 1 元 012 (cola,5C)

 無零錢 退 5 角 013 (OrangeJuice,5C)

 無零錢 送出橙汁 014 (Beer,5C)

 無零錢 送出啤酒 015 (OrangeJuice,4C)

 無零錢 Money Error 016 (Beer,4C)

 無零錢 Money Error 6)測試結(jié)果:所有測試都成功,且測試的覆蓋率為百分百

 五、分析與討論 該實驗借助了 Eclipse+JUnit+EclEmma 進行了測試。可以將代碼實現(xiàn)的功能過一遍。更快捷的找到自己的測試用例的不足。

 六、教師評語

 簽名:

 日期:

 成績

 附件:

 4 1、 傭金問題 5 實現(xiàn)代碼:

 6 package test4; 7

 8 import java.util.Scanner; 9

 10 public class Commission { 11

 12

  double totalspirit=0;//白酒總銷售量 13

  double totalredwine=0;//紅酒總銷售量 14

  double totalbeer=0;//啤酒總銷售量 15

 16

  double spiritprice=168;//白酒的單價 17

  double redwineprice=120;//紅酒的單價 18

  double beerprice=5;//啤酒的單價 19

 20

  double spiritsales; 21

  double redwinesales; 22

  double beersales; 23

  double sales; 24

 25

  double commission;//傭金 26

  String resultSales; 27

 28

  29

  public Commission(double spirit, double redwine, double beer) 30

  { 31

 totalspirit+=spirit; 32

 totalredwine=+redwine; 33

 totalbeer+=beer; 34

  } 35

  public String operation(double spirit, double redwine, double beer) 36

  { 37

 if(spirit>=50&&spirit<=5000) 38

 { 39

  if(redwine>=30&&redwine<=3000) 40

  { 41

 if(beer>=300&&beer<=30000) 42

 {

 43

 spiritsales=spiritprice*totalspirit; 44

 redwinesales=redwineprice*totalredwine; 45

 beersales=beerprice*totalbeer; 46

 sales=spiritsales+redwinesales+beersales; 47

  if(sales<=20000) 48

  commission=sales*0.04; 49

 else if(sales>20000&&sales<=45000) 50

  commission=20000*0.04+(sales-20000)*0.01; 51

 else 52

  commission=45000*0.01+(sales-45000)*0.005; 53

  resultSales="Current State\n" + 54

 "白酒銷售量: " + totalspirit + "\n" + 55

 "紅酒銷售量: " + totalredwine + "\n" + 56

 "啤酒銷售量: " + totalbeer + "\n" + 57

 "公司總銷售額: " + sales+"\n"+ 58

 "本月獲得傭金:"+commission; 59

 } 60

 else if(beer<300) 61

 { 62

  resultSales="You did not complete the company"s sales 63 index,at least a month to sell 300 bottles of beer."; 64

 } 65

 else if(beer>30000) 66

 { 67

  resultSales="Monthly supply of 30000 bottles of beer"; 68

 } 69

  } 70

  else if(redwine<30) 71

  { 72

 resultSales="You did not complete the company"s sales 73 index,at least a month to sell 30 bottles of red wine."; 74

  } 75

  else if(redwine>3000) 76

  { 77

 resultSales="Monthly supply of 3000 bottles of red wine"; 78

  } 79

 } 80

 else if(spirit<50) 81

 { 82

  resultSales="You did not complete the company"s sales index,at 83 least a month to sell 50 bottles of spirit."; 84

 } 85

 else if(spirit>5000) 86

 { 87

  resultSales="Monthly supply of 5000 bottles of spirit"; 88

 } 89

 return resultSales; 90

  } 91

  }

 92 測試代碼:

 93 package test4; 94

 95 import test3.SaleMachine; 96 import junit.framework.TestCase; 97

 98 public class TestCommission extends TestCase { 99

 public void testOperation1() 100

 { 101

  Commission saleMan1 = new Commission(55,40,400); 102

  String expectedResult = "Current State\n" + 103

 "白酒銷售量: " + 55.0 + "\n" + 104

 "紅酒銷售量: " + 40.0 + "\n" + 105

 "啤酒銷售量: " + 400.0 + "\n" + 106

 "公司總銷售額: " + 16040.0+"\n"+ 107

 "本月獲得傭金:"+641.6; 108

  assertEquals(expectedResult, saleMan1.operation(55,40,400)); 109

 } 110

 public void testOperation2() 111

 { 112

  Commission saleMan2 = new Commission(30,40,400); 113

  String expectedResult = "You did not complete the company"s sales index,at least a 114 month to sell 50 bottles of spirit."; 115

  assertEquals(expectedResult, saleMan2.operation(30,40,400)); 116

 } 117

 public void testOperation3() 118

 { 119

  Commission saleMan3 = new Commission(5500,40,400); 120

  String expectedResult = "Monthly supply of 5000 bottles of spirit"; 121

  assertEquals(expectedResult, saleMan3.operation(5500,40,400)); 122

 } 123

 public void testOperation4() 124

 { 125

  Commission saleMan4 = new Commission(55,25,400); 126

  String expectedResult ="You did not complete the company"s sales index,at least a 127 month to sell 30 bottles of red wine."; 128

  assertEquals(expectedResult, saleMan4.operation(55,25,400)); 129

 } 130

 public void testOperation5() 131

 { 132

  Commission saleMan5 = new Commission(55,4000,400); 133

  String expectedResult = "Monthly supply of 3000 bottles of red wine"; 134

  assertEquals(expectedResult, saleMan5.operation(55,4000,400)); 135

  } 136

 public void testOperation6() 137

 { 138

  Commission saleMan6 = new Commission(55,75,250); 139

  String expectedResult ="You did not complete the company"s sales index,at least a 140 month to sell 300 bottles of beer."; 141

  assertEquals(expectedResult, saleMan6.operation(55,75,250)); 142

 } 143

 public void testOperation7() 144

 { 145

  Commission saleMan7 = new Commission(55,75,33000); 146

  String expectedResult = "Monthly supply of 30000 bottles of beer"; 147

  assertEquals(expectedResult, saleMan7.operation(55,75,33000)); 148

 } 149

 public void testOperation8() 150

 { 151

  Commission saleMan8 = new Commission(100,150,1000); 152

  String expectedResult = "Current State\n" + 153

 "白酒銷售量: " + 100.0 + "\n" + 154

 "紅酒銷售量: " + 150.0 + "\n" + 155

 "啤酒銷售量: " + 1000.0 + "\n" + 156

 "公司總銷售額: " + 39800.0+"\n"+ 157

 "本月獲得傭金:"+998.0; 158

  assertEquals(expectedResult, saleMan8.operation(100,150,1000)); 159

 } 160

 public void testOperation9() 161

 { 162

  Commission saleMan9 = new Commission(250,1000,5000); 163

  String expectedResult = "Current State\n" + 164

 "白酒銷售量: " + 250.0 + "\n" + 165

 "紅酒銷售量: " + 1000.0 + "\n" + 166

 "啤酒銷售量: " + 5000.0 + "\n" + 167

 "公司總銷售額: " + 187000.0+"\n"+ 168

 "本月獲得傭金:"+1160.0; 169

  assertEquals(expectedResult, saleMan9.operation(250,1000,5000)); 170

 } 171 } 172

 173 2、 NextDate 問題

 174 實現(xiàn)代碼:

 175 package test4; 176

 177

 178 public class NextDay { 179

  180

  int year; 181

  int month; 182

  int day; 183

  int nextday; 184

  int nextmonth; 185

  int nextyear; 186

  String resultDate; 187

 188

  public NextDay(int year,int month,int day) 189

  { 190

 nextday = day; 191

 nextmonth=month; 192

 nextyear=year; 193

  } 194

  public String operation(int year,int month,int day) 195

  { 196

 if(1>month || month>12) 197

 { 198

  resultDate="This month not between 1 and 12"; 199

 } 200

 if(1>day || day>31) 201

 { 202

  resultDate="This day not between 1 and 31"; 203

 } 204

 else{ 205

 switch(month) 206

 { 207

 case (1): 208

 case (3): 209

 case (5): 210

 case (7): 211

 case (8): 212

 case (10): 213

 if(day<31) 214

 { 215

  nextday=day+1; 216

 } 217

 else if(day==31){ 218

  nextday=1; 219

  nextmonth=month+1; 220

 } 221

 resultDate="Tomorrow"s date 222 is:"+nextyear+"-"+nextmonth+"-"+nextday; 223

  break; 224

  225

  226

 case (4): 227

 case (6): 228

 case (9): 229

 case (11): 230

 if(day<30) 231

 { 232

  nextday=day+1; 233

 } 234

 else if(day==30) 235

 { 236

  nextday=1; 237

  nextmonth=month+1; 238

 } 239

 else if(day==31) 240

 { 241

  resultDate="Sorry.This month no 31 days!"; 242

  break; 243

 } 244

 resultDate="Tomorrow"s date 245 is:"+nextyear+"-"+nextmonth+"-"+nextday; 246

 break; 247

  248

 case (12): 249

 if(day<31) 250

 { 251

  nextday=day+1;

 252

 } 253

 else{ 254

  nextday=1; 255

  nextmonth=1; 256

  nextyear=year+1; 257

 } 258

 resultDate="Tomorrow"s date 259 is:"+nextyear+"-"+nextmonth+"-"+nextday; 260

 break; 261

 case (2): 262

  if(day<28) 263

 { 264

  nextday=day+1; 265

 } 266

 else if(day==28) 267

  { 268

  if((year%4==0&&year%100!=0)||year%400==0) 269

  { 270

 nextday=29; 271

  } 272

  else{ 273

 nextday=1; 274

 nextmonth=3; 275

  } 276

 } 277

 else if(day==29) 278

 { 279

  if((year%4==0 && year%100!=0) || year%400==0) 280

  { 281

 nextday=1; 282

 nextmonth=3; 283

  } 284

  else 285

  { 286

 resultDate="Sorry.This year"s 2nd month no 29 days!"; 287

 break; 288

  } 289

 } 290

 else if(day==30||day==31) 291

 { 292

  resultDate="Sorry.This month no 30 or 31 days!"; 293

  break; 294

 } 295

 resultDate="Tomorrow"s date 296 is:"+nextyear+"-"+nextmonth+"-"+nextday; 297

 break; 298

 } 299

  } 300

 return resultDate; 301 } 302

 303 } 304 測試代碼:

 305

 package test4; 306

 307 import junit.framework.TestCase; 308

 309 public class TestNextDay extends TestCase { 310

 public void testOperation1() 311

  { 312

  NextDay next1 = new NextDay(1993,-1,15); 313

  String expectedResult ="This month not between 1 and 12"; 314

  assertEquals(expectedResult, next1.operation(1993,-1,15)); 315

 } 316

 public void testOperation2() 317

 { 318

  NextDay next2 = new NextDay(1993,0,15); 319

  String expectedResult = "This month not between 1 and 12"; 320

  assertEquals(expectedResult, next2.operation(1993,0,15)); 321

 } 322

 public void testOperation3() 323

 { 324

  NextDay next3 = new NextDay(1993,1,15); 325

  String expectedResult = "Tomorrow"s date is:"+1993+"-"+1+"-"+16; 326

  assertEquals(expectedResult, next3.operation(1993,1,15)); 327

 } 328

 public void testOperation4() 329

 { 330

  NextDay next4 = new NextDay(1993,11,15); 331

  String expectedResult = "Tomorrow"s date is:"+1993+"-"+11+"-"+16; 332

  assertEquals(expectedResult, next4.operation(1993,11,15)); 333

 } 334

 public void testOperation5() 335

 { 336

  NextDay next5 = new NextDay(1993,12,15); 337

  String expectedResult = "Tomorrow"s date is:"+1993+"-"+12+"-"+16; 338

  assertEquals(expectedResult, next5.operation(1993,12,15)); 339

 } 340

 public void testOperation6() 341

 { 342

  NextDay next6 = new NextDay(1993,13,15); 343

  String expectedResult = "This month not between 1 and 12"; 344

  assertEquals(expectedResult, next6.operation(1993,13,15)); 345

 } 346

 public void testOperation7() 347

 { 348

  NextDay next7 = new NextDay(1993,6,-1); 349

  String expectedResult = "This day not between 1 and 31"; 350

  assertEquals(expectedResult, next7.operation(1993,6,-1)); 351

 } 352

 public void testOperation8() 353

 { 354

  NextDay next8 = new NextDay(1993,6,0); 355

 String expectedResult = "This day not between 1 and 31"; 356

  assertEquals(expectedResult, next8.operation(1993,6,0)); 357

 } 358

 public void testOperation9() 359

 { 360

  NextDay next9 = new NextDay(1993,6,1); 361

  String expectedResult = "Tomorrow"s date is:"+1993+"-"+6+"-"+2; 362

  assertEquals(expectedResult, next9.operation(1993,6,1)); 363

 } 364

 public void testOperation10() 365

 { 366

  NextDay next10 = new NextDay(1993,6,15); 367

  String expectedResult = "Tomorrow"s date is:"+1993+"-"+6+"-"+16; 368

  assertEquals(expectedResult, next10.operation(1993,6,15)); 369

 } 370

 public void testOperation11() 371

 { 372

  NextDay next11 = new NextDay(1993,6,29); 373

  String expectedResult ="Tomorrow"s date is:"+1993+"-"+6+"-"+30; 374

  assertEquals(expectedResult, next11.operation(1993,6,29)); 375

 } 376

 public void testOperation12() 377

 { 378

  NextDay next12 = new NextDay(1993,6,30); 379

  String expectedResult = "Tomorrow"s date is:"+1993+"-"+7+"-"+1; 380

  assertEquals(expectedResult, next12.operation(1993,6,30)); 381

 } 382

 public void testOperation13() 383

 { 384

  NextDay next13 = new NextDay(1993,6,31); 385

  String expectedResult = "Sorry.This month no 31 days!"; 386

  assertEquals(expectedResult, next13.operation(1993,6,31)); 387

 } 388

 public void testOperation14() 389

 { 390

  NextDay next14 = new NextDay(1993,2,-1); 391

  String expectedResult = "This day not between 1 and 31"; 392

  assertEquals(expectedResult, next14.operation(1992,3,-1)); 393

 } 394

 public void testOperation15() 395

 { 396

  NextDay next15 = new NextDay(1993,2,0); 397

  String expectedResult = "This day not between 1 and 31"; 398

  assertEquals(expectedResult, next15.operation(1993,2,0)); 399

  } 400

 public void testOperation16() 401

 { 402

  NextDay next16 = new NextDay(1993,2,1); 403

  String expectedResult = "Tomorrow"s date is:"+1993+"-"+2+"-"+2; 404

  assertEquals(expectedResult, next16.operation(1993,2,1)); 405

 } 406

 public void testOperation17() 407

 { 408

  NextDay next17 = new NextDay(1993,2,15); 409

  String expectedResult ="Tomorrow"s date is:"+1993+"-"+2+"-"+16; 410

  assertEquals(expectedResult, next17.operation(1993,2,15)); 411

 } 412

 public void testOperation18() 413

 { 414

  NextDay next18 = new NextDay(1992,2,28); 415

  String expectedResult ="Tomorrow"s date is:"+1992+"-"+2+"-"+29; 416

  assertEquals(expectedResult, next18.operation(1992,2,28)); 417

 } 418

 public void testOperation29() 419

 { 420

  NextDay next29 = new NextDay(1993,2,28); 421

  String expectedResult ="Tomorrow"s date is:"+1993+"-"+3+"-"+1; 422

  assertEquals(expectedResult, next29.operation(1993,2,28)); 423

 } 424

 public void testOperation19() 425

 { 426

  NextDay next19 = new NextDay(1992,2,29); 427

  String expectedResult ="Tomorrow"s date is:"+1992+"-"+3+"-"+1; 428

  assertEquals(expectedResult, next19.operation(1992,2,29)); 429

 } 430

 public void testOperation20() 431

 { 432

  NextDay next20 = new NextDay(1993,2,29); 433

  String expectedResult ="Sorry.This year"s 2nd month no 29 days!"; 434

  assertEquals(expectedResult, next20.operation(1993,2,29)); 435

 } 436

 public void testOperation21() 437

 { 438

  NextDay next21 = new NextDay(1993,2,30); 439

  String expectedResult ="Sorry.This month no 30 or 31 days!"; 440

  assertEquals(expectedResult, next21.operation(1993,2,30)); 441

 } 442

 public void testOperation22() 443

  { 444

  NextDay next22 = new NextDay(1993,2,31); 445

  String expectedResult = "Sorry.This month no 30 or 31 days!"; 446

  assertEquals(expectedResult, next22.operation(1993,2,31)); 447

 } 448

 public void testOperation23() 449

 { 450

  NextDay next23 = new NextDay(1993,12,-1); 451

  String expectedResult = "This day not between 1 and 31"; 452

  assertEquals(expectedResult, next23.operation(1993,12,-1)); 453

 } 454

 public void testOperation24() 455

 { 456

  NextDay next24 = new NextDay(1993,12,0); 457

  String expectedResult = "This day not between 1 and 31"; 458

  assertEquals(expectedResult, next24.operation(1993,12,0)); 459

 } 460

 public void testOperation25() 461

 { 462

  NextDay next25 = new NextDay(1993,12,1); 463

  String expectedResult = "Tomorrow"s date is:"+1993+"-"+12+"-"+2; 464

  assertEquals(expectedResult, next25.operation(1993,12,1)); 465

 } 466

 public void testOperation26() 467

 { 468

  NextDay next26 = new NextDay(1993,12,30); 469

  String expectedResult = "Tomorrow"s date is:"+1993+"-"+12+"-"+31; 470

  assertEquals(expectedResult, next26.operation(1993,12,30)); 471

 } 472

 public void testOperation27() 473

 { 474

  NextDay next27 = new NextDay(1993,12,31); 475

  String expectedResult ="Tomorrow"s date is:"+1994+"-"+1+"-"+1; 476

  assertEquals(expectedResult, next27.operation(1993,12,31)); 477

 } 478

 public void testOperation28() 479

 { 480

  NextDay next28 = new NextDay(1993,12,32); 481

  String expectedResult ="This day not between 1 and 31"; 482

  assertEquals(expectedResult, next28.operation(1993,12,32)); 483

 } 484

 public void testOperation30() 485

 { 486

  NextDay next30 = new NextDay(1993,1,-1); 487

 String expectedResult ="This day not between 1 and 31"; 488

  assertEquals(expectedResult, next30.operation(1993,1,-1)); 489

 } 490

 public void testOperation31() 491

 { 492

  NextDay next31 = new NextDay(1993,1,0); 493

  String expectedResult ="This day not between 1 and 31"; 494

  assertEquals(expectedResult, next31.operation(1993,1,0)); 495

 } 496

 public void testOperation32() 497

 { 498

  NextDay next32 = new NextDay(1993,1,1); 499

  String expectedResult ="Tomorrow"s date is:"+1993+"-"+1+"-"+2; 500

  assertEquals(expectedResult, next32.operation(1993,1,1)); 501

 } 502

 public void testOperation33() 503

 { 504

  NextDay next33 = new NextDay(1993,1,30); 505

  String expectedResult ="Tomorrow"s date is:"+1993+"-"+1+"-"+31; 506

  assertEquals(expectedResult, next33.operation(1993,1,30)); 507

 } 508

 public void testOperation34() 509

 { 510

  NextDay next34 = new NextDay(1993,1,31); 511

  String expectedResult ="Tomorrow"s date is:"+1993+"-"+2+"-"+1; 512

  assertEquals(expectedResult, next34.operation(1993,1,31)); 513

 } 514

 public void testOperation35() 515

 { 516

  NextDay next35 = new NextDay(1993,1,32); 517

  String expectedResult ="This day not between 1 and 31"; 518

  assertEquals(expectedResult, next35.operation(1993,1,32)); 519

 } 520 } 521

 522 3、 自動售貨機問題

 523 實現(xiàn)代碼:

 524 package test4; 525

 526 public class SaleMachine { 527

 private int countOfBeer, countOfOrangeJuice, countOfFiveCents, 528

 countOfOneDollar; 529

 private String[] typeOfGoods = { "Beer", "OrangeJuice" }; 530

 private String resultOfDeal; 531

  532

 public SaleMachine() { 533

  initial(); 534

 } 535

 536

 public void initial() { 537

  countOfBeer = 6; 538

  countOfOrangeJuice = 6; 539

  countOfFiveCents = 6; 540

  countOfOneDollar = 6; 541

 } 542

 543

 public SaleMachine(int fiveCents, int oneDollar, int numOfBeer, 544

 int numOfOrange) 545

 546

 { 547

  countOfFiveCents = fiveCents; 548

  countOfOneDollar = oneDollar; 549

  countOfBeer = numOfBeer; 550

  countOfOrangeJuice = numOfOrange; 551

 } 552

 553

 public String operation(String type, String money) 554

 555

 { 556

  if (countOfFiveCents <= 0) { 557

 if (money.equalsIgnoreCase("5C")) { 558

  if (type.equals(typeOfGoods[0])) { 559

 resultOfDeal = "give you a bottle Beer."; 560

 return resultOfDeal; 561

  } else if (type.equals(typeOfGoods[1])) { 562

 resultOfDeal = "give you a bottle OrangeJuice."; 563

 return resultOfDeal; 564

  } else { 565

 resultOfDeal = "Back 5 Cents."; 566

 return resultOfDeal; 567

  } 568

 } 569

 if (money.equalsIgnoreCase("1D")) { 570

  if (type.equals(typeOfGoods[0])) { 571

 resultOfDeal = "Turn on the red light \n" + "Back 1 Dollar"; 572

 return resultOfDeal; 573

  } else if (type.equals(typeOfGoods[1])) { 574

 resultOfDeal = "Turn on the red light \n" + "Back 1 Dollar"; 575

  return resultOfDeal; 576

  } else { 577

 resultOfDeal = "Back 1 Dollar"; 578

 return resultOfDeal; 579

  } 580

 } else { 581

  resultOfDeal = "Money Error."; 582

  return resultOfDeal; 583

 } 584

  } else { 585

 if (money.equalsIgnoreCase("1D")) { 586

  if (type.equals(typeOfGoods[0])) { 587

 resultOfDeal = "give you a bottle Beer.\n" 588

 + "Back 5 Cents."; 589

 return resultOfDeal; 590

  } else if (type.equals(typeOfGoods[1])) { 591

 resultOfDeal = "give you a bottle OrangeJuice.\n" 592

 + "Back 5 Cents."; 593

 return resultOfDeal; 594

  } else { 595

 resultOfDeal = "Type Error"; 596

 return resultOfDeal; 597

  } 598

 } else if (money.equalsIgnoreCase("5C")) { 599

  if (type.equals(typeOfGoods[0])) { 600

 resultOfDeal = "give you a bottle Beer.\n"; 601

 return resultOfDeal; 602

  } else if (type.equals(typeOfGoods[1])) { 603

 resultOfDeal = "give you a bottle OrangeJuice.\n"; 604

 return resultOfDeal; 605

  } else { 606

 resultOfDeal = "Type Error" + "Back Money"; 607

 return resultOfDeal; 608

  } 609

 } else { 610

  resultOfDeal = "Money Error"; 611

  return resultOfDeal; 612

 } 613

  } 614

 } 615 } 616

 617 測試代碼:

 618 package test4; 619

  620 import test4.SaleMachine; 621 import junit.framework.TestCase; 622

 623 public class TestSaleMachine extends TestCase { 624

 public void testOperation1() { 625

  SaleMachine saleMachine1 = new SaleMachine(); 626

  String expectedResult =

 "Type Error"; 627

  assertEquals(expectedResult, saleMachine1.operation("cola", "1D")); 628

 } 629

 630

 public void testOperation2() { 631

  SaleMachine saleMachine2 = new SaleMachine(); 632

  String expectedResult = "give you a bottle OrangeJuice.\n"+"Back 5 Cents."; 633

  assertEquals(expectedResult, 634

  saleMachine2.operation("OrangeJuice", "1D")); 635

 } 636

 637

 public void testOperation3() { 638

  SaleMachine saleMachine3 = new SaleMachine(); 639

  String expectedResult = "give you a bottle Beer.\n"+"Back 5 Cents."; 640

  assertEquals(expectedResult, saleMachine3.operation("Beer", "1D")); 641

 } 642

 643

 public void testOperation4() { 644

  SaleMachine saleMachine4 = new SaleMachine(); 645

  String expectedResult = "Type Error"+"Back Money"; 646

  assertEquals(expectedResult, saleMachine4.operation("cola", "5C")); 647

 } 648

 649

 public void testOperation5() { 650

  SaleMachine saleMachine5 = new SaleMachine(); 651

  String expectedResult = "give you a bottle OrangeJuice.\n"; 652

  assertEquals(expectedResult, 653

  saleMachine5.operation("OrangeJuice", "5C")); 654

 } 655

 656

 public void testOperation6() { 657

  SaleMachine saleMachine6 = new SaleMachine(); 658

  String expectedResult =

 "give you a bottle Beer.\n"; 659

  assertEquals(expectedResult, saleMachine6.operation("Beer", "5C")); 660

 } 661

 662

 public void testOperation7() { 663

 SaleMachine saleMachine7 = new SaleMachine(); 664

  String expectedResult ="Money Error"; 665

  assertEquals(expectedResult, 666

  saleMachine7.operation("OrangeJuice", "4C")); 667

 } 668

 669

 public void testOperation8() { 670

  SaleMachine saleMachine8 = new SaleMachine(); 671

  String expectedResult ="Money Error"; 672

  assertEquals(expectedResult, saleMachine8.operation("Beer", "4C")); 673

 } 674

 675

 public void testOperation9() { 676

  SaleMachine saleMachine9 = new SaleMachine(0, 6, 6, 6); 677

  String expectedResult = "Back 1 Dollar"; 678

  assertEquals(expectedResult, saleMachine9.operation("cola", "1D")); 679

 } 680

 681

 public void testOperation10() { 682

  SaleMachine saleMachine10 = new SaleMachine(0, 6, 6, 6); 683

  String expectedResult = "Turn on the red light \n" + "Back 1 Dollar"; 684

  assertEquals(expectedResult, 685

  saleMachine10.operation("OrangeJuice", "1D")); 686

 } 687

  688

 public void testOperation11() { 689

  SaleMachine saleMachine11 = new SaleMachine(0, 6, 6, 6); 690

  String expectedResult = "Turn on the red light \n" + "Back 1 Dollar"; 691

  assertEquals(expectedResult, 692

  saleMachine11.operation("Beer", "1D")); 693

 } 694

  695

 public void testOperation12() { 696

  SaleMachine saleMachine12 = new SaleMachine(0,6,6,6); 697

  String expectedResult ="Back 5 Cents."; 698

  assertEquals(expectedResult, saleMachine12.operation("cola", "5C")); 699

 } 700

 public void testOperation13() { 701

  SaleMachine saleMachine13 = new SaleMachine(0,6,6,6); 702

  String expectedResult = "give you a bottle OrangeJuice."; 703

  assertEquals(expectedResult, saleMachine13.operation("OrangeJuice", "5C")); 704

 } 705

 public void testOperation14() { 706

  SaleMachine saleMachine14 = new SaleMachine(0,6,6,6); 707

 String expectedResult = "give you a bottle Beer."; 708

  assertEquals(expectedResult, saleMachine14.operation("Beer", "5C")); 709

 } 710

 public void testOperation15() { 711

  SaleMachine saleMachine13 = new SaleMachine(0,6,6,6); 712

  String expectedResult = "Money Error."; 713

  assertEquals(expectedResult, saleMachine13.operation("OrangeJuice", "4C")); 714

 } 715

 public void testOperation16() { 716

  SaleMachine saleMachine16 = new SaleMachine(0,6,6,6); 717

  String expectedResult = "Money Error."; 718

  assertEquals(expectedResult, saleMachine16.operation("Beer", "4C")); 719

 } 720 } 721

 722

 723

推薦訪問: 實驗 測試 報告

【黑盒測試實驗報告】相關(guān)推薦

工作總結(jié)最新推薦

NEW
  • 同志們:今天這個大會,是市委全面落實黨要管黨、從嚴治黨要求的一項重大舉措,也是對縣市區(qū)委書記履行基層黨建工作第一責任人情況的一次集中檢閱,同時是對全市基層黨建工作的一次再部署、再落實的會議。前面,**

  • ***年,我認真履行領(lǐng)班子、帶隊伍、抓黨員、保穩(wěn)定的基層黨建工作思路,以學習貫徹習近平新時代中國特色社會主義思想和黨的十九大歷次全會精神為主線,以市局基層黨建工作考核細則為落腳點,落實全面從嚴治黨主體

  • 根據(jù)會議安排,現(xiàn)將2022年履行抓基層黨建工作職責情況報告如下:一、履職工作特色和亮點1 突出政治建設(shè),著力在思想認識上提高。牢固樹立抓黨建就是抓政績的理念,以“黨建工作抓引領(lǐng)、社區(qū)治理求突破,為民服

  • 2022年以來,在**黨委的正確領(lǐng)導下,堅持以習近平新時代中國特色社會主義思想為指導,深入學習宣傳貫徹黨的二十大精神,以黨建工作為統(tǒng)領(lǐng),扎實開展夯實“三個基本”活動,以“四化四力”行動為抓手,聚力創(chuàng)建

  • 各位領(lǐng)導,同志們:根據(jù)會議安排,現(xiàn)就2022年度抓基層黨建工作情況匯報如下:一、主要做法及成效(一)強化政治引領(lǐng)。一是不斷強化理論武裝。堅持通過黨組會、中心組學習會和“三會一課”,第一時間、第一議題學

  • 2022年度抓基層黨建工作述職報告按照黨委工作部署,現(xiàn)將本人2022年度抓基層黨建工作情況報告如下:一、2022年度抓基層黨建工作情況(一)旗幟鮮明講政治將旗幟鮮明講政治放在全局發(fā)展首要位置,積極開展

  • 2022年,是我在數(shù)計系黨總支書記這個新崗位上度過的第一個完整的工作年度。回首一年來在校黨委的正確領(lǐng)導下,與數(shù)計系領(lǐng)導班子和全體師生共同走過的日子,艱辛歷歷在目,收獲溫潤心田。作為黨總支書記,我始終牢

  • 按照考核要求,現(xiàn)將本人一年來,作為統(tǒng)戰(zhàn)部長履行職責、廉潔自律等方面情況報告如下:一、著眼增強政治素質(zhì),不斷深化理論學習堅持把旗幟鮮明講政治作為履職從政的第一位要求,帶領(lǐng)統(tǒng)戰(zhàn)系統(tǒng)干部堅決擁護“兩個確立”

  • **年,緊緊圍繞黨工委、管委會的決策部署,全體人員團結(jié)協(xié)作、凝心聚力,緊扣黨工委“**”基本工作思路,全力開拓進取,認真履職盡責,圓滿完成各項工作任務(wù)。一、個人思想政治狀況檸檬文苑www bgzjy

  • 按照縣委關(guān)于開展抓基層黨建述職評議會議的有關(guān)要求,經(jīng)請示縣委組織部同意,今天,我們在此召開2022年度基層黨組織書記抓基層黨建述職評議會議。1 首先,請**黨委書記,**同志述職。**黨委能夠主動研究