Tugas 2 Testing&Dokumentasi 1). 0014 function SquareRoot( Number : in FLOAT; 0015 Accuracy : in FLOAT) return FLOAT is 0016 0017 MaximumValue : FLOAT; 0018 MinimumValue : FLOAT; 0019 CurrentGuess : FLOAT; 0020 CurrentGuessSquared : FLOAT; 0021 CurrentError : FLOAT; 0022 CloseEnough : BOOLEAN := FALSE; 0023 0024 begin -- SquareRoot 0025 if Number > 1.0 then 0026 MaximumValue := Number; 0027 MinimumValue := 0.0; 0028 else 0029 MaximumValue := 1.0; 0030 MinimumValue := Number; 0031 end if; 0032 while not CloseEnough loop 0033 CurrentGuess := (MaximumValue + MinimumValue) / 2.0; 0034 CurrentGuessSquared := CurrentGuess * CurrentGuess; 0035 CurrentError := abs( Number - CurrentGuessSquared); 0036 if CurrentError <= Accuracy then 0037 CloseEnough := TRUE; 0038 else 0039 if CurrentGuessSquared >= Number then 0040 MaximumValue := CurrentGuess; 0041 else 0042 MinimumValue := CurrentGuess; 0043 end if; 0044 end if; 0045 end loop; 0046 return CurrentGuess; 0047 end SquareRoot;
2).
0001 procedure GetValidPurchasePrice( ValidPrice : out FLOAT) is 0002 0003 IsValidPrice : BOOLEAN := FALSE; 0004 PossiblePrice : FLOAT; 0005 0006 begin -- GetValidPurchasePrice 0007 while not IsValidPrice loop 0008 begin -- posit/ admit block 0009 PUT("Please enter the purchase price "); 0010 -- implicit exception may be raised here 0011 GET( PossiblePrice); SKIP_LINE; 0012 if PossiblePrice <= MinPrice or 0013 PossiblePrice > MaxPrice then 0014 -- raise explicit exception 0015 raise DATA_ERROR; 0016 end if; 0019 IsValidPrice := TRUE; 0018 exception 0019 when DATA_ERROR => 0020 SKIP_LINE; 0021 PUT("This value is invalid!"); NEW_LINE; 0022 PUT("Please enter a value "); 0023 PUT("(including decimal parts) between "); 0024 PUT( MinPrice, EXP=>0, FORE=>4, AFT=>2); 0025 PUT(" and "); 0026 PUT( MaxPrice, EXP=>0, FORE=>4, AFT=>2); 0027 NEW_LINE; 0028 end; -- posit/ admit block 0029 end loop; 0030 ValidPrice := PossiblePrice; 0031 end GetValidPurchasePrice;
Untuk nomer 1 & 2:
a. Dengan mempergunakan perancangan prosedural atau source code sebagai dasar, gambarkan flowgraph
b. Tentukan cyclomatic complexity flowgraph yang telah dibuat
c. Tentukan independent path pada flowgraph
d. Buat test case yang akan mengerjakan masing-masing path pada basis set. Data yang dipilih harus tepat sehingga setiap kondisi dari predicate node dikerjakan semua.
e. Testing menggunakan Graph Matrix
3). Berikan contoh (masing-masing minimal 5) perangkat lunak yang bisa dilakukan pengujian dengan menggunakan Black Box Testing:
- Graph based Testing
- Equivalence Partitioning
- Boundary Value Analysis
- Comparison Testing
Advertisement