您的当前位置:首页正文

Software Test 软件测试实验报告

2021-01-26 来源:步旅网


Dalian Nationalities University Computer Science and Engineering Lab

Report

Experimental Subject: CoffeeMaker Integration Testing

Course Title: Software Quality Assurance and Testing Experiment Type:□Verification □Operating □Design █Composite Major:SE Class:102 Name:Tengfei Yang ID:2010082225 Exp Date:April 18th,2013 Exp Location:media room (2) Exp Hours:4 Scores:

Signature of instructor: April 22nd,2013

1. Experimental Subject:

CoffeeMaker Integration Testing

2. Experimental Purposes:

Learning how to use the Static White-box and Dynamic

Black-box Testing to find bugs in Program.

Learning how to do Unit Testing for a project in MyEclipse using

Junit .

3. Experimental Procedures:

First of all, Read codes of the Coffeemaker, give it a Static White-box Testing.The following are some obvious bugs we can easily find by read the codes.

Defect records NO.LocationDescribeTypeSolutionDefectLevelif(r.equals(recipeArray[i])) {can't delete a existalgorithmicrecipeArray[i] = new Recipe();1deleteRecipe()RecipeerrorcanDeleteRecipe = true;seriouswhen sugar>0,we2addInventory()can't add inventorysuccessfullyif(amtCoffee < 0 || amtMilk < 0 ||amtSugar < 0 || amtChocolate < 0)algorithmic{canAddInventory = false;error}serious

Secondly,run the project in MyEclipse, The tests outlined below are the Black-box test cases for the Coffee Maker.

Test IDDescriptionPrecondition: Run CoffeeMakerEnter: Menu option 1, \"Add a recipe \"Name: CoffeePrice: 50Coffee: 3Milk: 1Sugar: 1Chocolate: 0Return to main menu.Precondition: Run CoffeeMakerEnter: Menu option 1, \"Add a recipe \"Name: MochaPrice: -50Return to main menu.Precondition: Run CoffeeMakerEnter: Menu option 1, \"Add a recipe \"Name: MochaPrice: 60Coffee: aReturn to main menu.Precondition: Run CoffeeMakerEnter: Menu option 2, \"Delete a recipe \"Return to main menu.Precondition: addRecipe1 has run successfullyEnter: Menu option 3, \"Edit a recipe \"Select: CoffeePrice: aReturn to main menu.Precondition: Run CoffeeMakerEnter: Menu option 4, \"Add inventory\"ExpectedResultsActualResultsaddRecipe1Coffeesuccessfullyadded at thefirstlocation.coffee beadded at thefourthlocationaddRecipe2Mocha couldnot be added.Price can notbe negative.the same asexpectedaddRecipe3Please inputan integer..the same asexpecteddeleteRecipeThere are norecipes todeletethe same asexpectededitRecipePlease inputan integer.the same asexpectedaddInventory1Coffee: -1Return to main menu.Precondition: Run CoffeeMakerEnter: Menu option 4, \"Add inventory\"Cannot addinventory.the same asUnits ofexpectedcoffee can notbe negativeaddInventory2Coffee: aReturn to main menu.Precondition:Run CoffeeMakerEnter: Menu option 5, \"Check inventory\"Return to main menu.Please inputan integer.the same asexpectedCoffee: 15Milk: 15checkInventorySugar: 15Chocolate: 15Your change isPrecondition: addRecipe1 has successfully run10.Enter: Menu option 6, \"Make coffee \"Select: CoffeeCoffee: 12purchaseBeverageAmount: 60Milk: 14Return to main menu.Sugar: 14Enter: Menu option 5, \"Check inventory \"Chocolate: 15Return to main menu.the same asexpectedthe same asexpected So we can know that there is a bug in the function addRecipe()

NO.LocationDescribeTypeSolutionDefectLevel3addRecipe()when add a newrecipe,it will beadded at the endif(!recipeFull[i]) {emptySpot = i;algorithmiccanAddRecipe = true;errorbreak;}normal

Finally, we do Unit Testing for CoffeMaker in MyEclipse using Junit . The code below are the Unit test cases for the Coffee Maker.

package cn.edu.dlnu.st.coffeemaker;

import cn.edu.dlnu.st.coffeemaker.exceptions.InventoryException; import junit.framework.TestCase;

public class CoffeeMakerTest extends TestCase {

protected void setUp() throws Exception {

cm = new CoffeeMaker(); r = new Recipe();

r.setName(\"Coffee\"); r.setAmtChocolate(\"2\"); r.setAmtCoffee(\"3\"); r.setAmtMilk(\"1\"); r.setAmtSugar(\"1\"); r.setPrice(\"50\");

private CoffeeMaker cm; private Recipe r;

}

super.setUp();

public void testMakeCoffee() {

cm.addRecipe(r);

assertEquals(25, cm.makeCoffee(1, 75));

assertEquals(13, cm.inventory.getChocolate() ); assertEquals(12, cm.inventory.getCoffee()); assertEquals(14, cm.inventory.getMilk()); assertEquals(14, cm.inventory.getSugar()); }

}

Defect records NO.LocationDescribeTypeSolutionDefectLevelif(canMakeCoffee) {when make ainventory.setCoffee(inventorycoffee,the inventoryalgorithmic.getCoffee() -seriousof coffee doesn'terrorr.getAmtCoffee());reduce but go up4MakeCoffee()

4. Experiences

It is the first time for me to use a complete set of test methods to test a program. What I want to say is :It’s really worked!Actually if I don’t use the test methods like Dynamic Black-box Test or Unit Test method I do can find some bugs in a program, but there are always some deeply hidden bugs I can’t check out. I have learned that only use a scientific testing method can we assure the quality of software.

因篇幅问题不能全部显示,请点此查看更多更全内容