Sunteți pe pagina 1din 13

MATERIALES DE TRABAJO DE EVOLUCIN Y PRUEBAS DE SOFTWARE

PRCTICA DE LABORATORIO N 01
Seccin : ..
Docente : Daniel Gamarra Moreno
Unidad ;
Semana : .
Instrucciones

Apellidos
Nombres
Fecha

: ..
: ..
: // Duracin: .

: Desarrolle las actividades solicitadas.

PRUEBAS UNITARIAS CON NUNIT


PROYECTO MINICALC
EJERCICIO 1: CREAR SOLUCION Y PROYECTOS
1.

Crear una solucin en blanco llamado MiniCalc.

2.

Aadir un proyecto C# Windows Forms Application, llamado MiniCalc.

3.

Aadir un proyecto C# Unit Test Project, llamado CalcTest.

4.

Renombrar la clase UnitTest1 por CalcTest.

5.

Inserte el siguiente cdigo en la clase CalcTest.:


using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace CalcTest
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void PruebaFalla()
{
Console.Out.WriteLine("Llamando a PruebaFalla");
Assert.Fail("Esta prueba falla!");
}
[TestMethod]
public void PruebaExito()
{
Console.Out.WriteLine("Llamando a PruebaExito");
Assert.IsTrue(true,"Esta prueba es un exito!");
}
}
}

6.

Construya la solucin (Biuld Solution).

7.

Corra la pruebas.

EJERCICIO 2: ESCRIBIR UNA PRUEBA Y PROBAR ALGUNA FUNCIONALIDAD


1.

Aada el mtodo TestAdd a la clase CalcTest.


[TestMethod]
public void TestAdd()
{
Console.Out.WriteLine("TestAddition called");
Calculator testCalc = new Calculator();
//test for case of zeros'
Assert.AreEqual(0, testCalc.Add(0, 0), "Adding 0 to 0 should produce 0");
//test that param ordering isn't important

MATERIALES DE TRABAJO DE EVOLUCIN Y PRUEBAS DE SOFTWARE


Assert.AreEqual(1, testCalc.Add(1, 0), "Adding 1 to 0 should produce 1");
Assert.AreEqual(1, testCalc.Add(0, 1), "Adding 0 to 1 should produce 1");
//test for non zero case
Assert.AreEqual(3, testCalc.Add(1, 2), "Adding 1 to 2 should produce 3");
int nResult;
try
{
nResult = testCalc.Add(int.MaxValue, int.MaxValue);
Assert.Fail("Should throw a ResultOutofRangeException");
}
catch (ResultOutOfRangeException)
{
}
testCalc = null;
}

2.

Aada la clase Calculator.

3.

Crea el esqueleto de la clase Calculator y la excepcion.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MiniCalc
{
public class ResultOutOfRangeException : ApplicationException
{
}
public class Calculator
{
public int Add(int a, int b)
{
return 0;
}
}
}

4.

Remueva los mtodos PruebeFalla y PruebaExito de CalcTest.

5.

Aadir la referencia MiniCalc a CalcTest.

6.

Inserte la directiva using MiniCalc; en el archivo CalcTest.cs

7.

Compila el proyecto (Build Solution).

8.

Corra la prueba y .. falla la prueba porque falta la funcionalidad.

9.

Modifica el mtodo Add de Calculator, para darle funcionalidad.


public int Add(int a, int b)
{
return a + b;
}

10. Falla la prueba debido a que no se lanza la excepcin.


11. Modifica el mtodo Add, que incluye la excepcin.
public int Add(int a, int b)
{
int result;
result = a + b;
if (result < 0)
{
ResultOutOfRangeException rangeEx = new ResultOutOfRangeException();

MATERIALES DE TRABAJO DE EVOLUCIN Y PRUEBAS DE SOFTWARE


throw rangeEx;
}
return result;
}

12. Compila el proyecto (Build Solution) y corra el NUnit.

EJERCICIO 3: CONECTE LA LOGICA DE NEGOCIO A LA INTERFACE DE USUARIO


1.

Crea la siguiente interface:

Figura 1. Interface de usuario Proyecto MiniCalc.

Aada dos controles NumericUpDown llamados NumberA y NumberB, una etiqueta con el texto +, un botn
llamado EqualsButton con el texto = y una etiqueta llamada Result (mostrado como 3 en la figura).
2.

Doble click en el control EqualsButton para generar el evento handler. En este evento inserte el siguiente cdigo.
private void EqualsButton_Click(object sender, EventArgs e)
{
try
{
Calculator calc = new Calculator();
Result.Text = (calc.Add((int)NumberA.Value, (int)NumberB.Value).ToString());
}
catch (ResultOutOfRangeException)
{
Result.Text = "Out of Range";
}
}

3.

Construya la solucin (Biuld Solution) y ejecuta la aplicacin.

Usar una capa de interface te permite probar la lgica de negocio y cambiar la capa de interface sin cambiar la lgica
de negocio. Adems, es una buena prctica.

EJERCICIO 4: CONECTE LA LOGICA DE NEGOCIO A UNA INTERFACE DIFERENTE


1.

Cambie el cdigo del mtodo main de la clase MiniCalc al siguiente cdigo.


static void Main()
{
int nA, nB;
string result;
Console.WriteLine("Welcome to Mini Calc");
Console.WriteLine("Please enter the first number to add");
nA = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Please enter the second number to add");
nB = Convert.ToInt32(Console.ReadLine());
try
{
Calculator calc = new Calculator();
result = (calc.Add(nA, nB)).ToString();
}
catch (ResultOutOfRangeException)
{
result = "Out of Range";
}
Console.WriteLine(result);
Console.ReadLine();
}

MATERIALES DE TRABAJO DE EVOLUCIN Y PRUEBAS DE SOFTWARE


2.

Cambie la propiedad del proyecto. (Botn derecho en la solucin explorer) Configurar la salida Console
aplication.

3.

Construya la solucin (Biuld Solution) y ejecuta la aplicacin desde la lnea de comandos.

Al desarrollar el software aplicando las pruebas unitarias, uno de las reglas es: Si puedo pensar una forma de romper
la aplicacin, escriba una prueba para comprobar que puede romperla.

EJERCICIO 5: ESCRIBIR UNA PRUEBA PARA CORREGIR UN BUG


1.

En la clase Calctest aada el mtodo TestAddNegatives.


[TestMethod]
public void TestAddNegatives()
{
Console.Out.WriteLine("TestAddNegatives called");
Calculator testCalc = new Calculator();
int nResult;
try
{
nResult = testCalc.Add(-1, 0);
Assert.Fail("Should throw a NegativeParameterException");
}
catch (NegativeParameterException )
{ }
try
{
nResult = testCalc.Add(0, -1);
Assert.Fail("Should throw a NegativeParameterException");
}
catch (NegativeParameterException)
{ }
try
{
nResult = testCalc.Add(int.MinValue, int.MinValue);
Assert.Fail("Should throw a NegativeParameterException");
}
catch (NegativeParameterException)
{ }
testCalc = null;
}

2.

Note que hemos aadido un nuevo tipo de excepcin, por lo debemos tener una clase o un mtodo en la prueba.
Necesitamos crear la excepcin en el archivo de la Clase Calculator.
public class NegativeParameterException:ApplicationException
{
}

3.

Compila y corra las pruebas de nuevo. La prueba de fracasar, como se esperaba. Escriba el cdigo para
arreglarla. Correr las pruebas es una buena prctica.
public int Add(int a, int b)
{
int result;
if (a < 0 || b < 0 )
{
NegativeParameterException npEx = new NegativeParameterException();
throw npEx;
}
result = a + b;
if (result < 0)
{
ResultOutOfRangeException rangeEx = new ResultOutOfRangeException();
throw rangeEx;
}
return result;

MATERIALES DE TRABAJO DE EVOLUCIN Y PRUEBAS DE SOFTWARE


}

4.

Compila y corral as pruebas. La prueba es exitosa.

A estas alturas el cdigo de CalcTests es el siguiente.


using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MiniCalc;
namespace CalcTest
{
[TestClass]
public class CalcTest
{
[TestMethod]
public void TestAdd()
{
Console.Out.WriteLine("TestAddition called");
Calculator testCalc = new Calculator();
//test for case of zeros'
Assert.AreEqual(0, testCalc.Add(0, 0), "Adding 0 to 0 should produce 0");
//test that param ordering isn't important
Assert.AreEqual(1, testCalc.Add(1, 0), "Adding 1 to 0 should produce 1");
Assert.AreEqual(1, testCalc.Add(0, 1), "Adding 0 to 1 should produce 1");
//test for non zero case
Assert.AreEqual(3, testCalc.Add(1, 2), "Adding 1 to 2 should produce 3");
int nResult;
try
{
nResult = testCalc.Add(int.MaxValue, int.MaxValue);
Assert.Fail("Should throw a ResultOutofRangeException");
}
catch (ResultOutOfRangeException)
{
}
testCalc = null;
}
[TestMethod]
public void TestAddNegatives()
{
Console.Out.WriteLine("TestAddNegatives called");
Calculator testCalc = new Calculator();
int nResult;
try
{
nResult = testCalc.Add(-1, 0);
Assert.Fail("Should throw a NegativeParameterException");
}
catch (NegativeParameterException)
{}
try
{
nResult = testCalc.Add(0, -1);
Assert.Fail("Should throw a NegativeParameterException");
}
catch (NegativeParameterException)
{}
try
{
nResult = testCalc.Add(int.MinValue, int.MinValue);
Assert.Fail("Should throw a NegativeParameterException");
}
catch (NegativeParameterException)
{}
testCalc = null;
}
}
}

MATERIALES DE TRABAJO DE EVOLUCIN Y PRUEBAS DE SOFTWARE

EJERCICIO 6: ESCRIBIR UNA PRUEBA Y LUEGO OTRA FUNCION


1.

Aada un nuevo mtodo a CalcTests llamado TestSubtract.


[TestMethod]
public void TestSubtract()
{
Console.Out.WriteLine("TestSubtract called");
Calculator testCalc = new Calculator();
int nResult;
Assert.AreEqual(0, testCalc.Subtract(0, 0), "Subtracting 0 from 0 should produce 0");
Assert.AreEqual(1, testCalc.Subtract(0, 1), "Subtracting 0 from 1 should produce 1");
try
{
nResult = testCalc.Subtract(1, 0);
Assert.Fail("Subtracting 1 from 0 should throw a ResultOutofRangeException");
}
catch (ResultOutOfRangeException)
{ }
Assert.AreEqual(0,testCalc.Subtract(int.MaxValue, int.MaxValue), "Subtracting max value from max value should produce 0");
try
{
nResult = testCalc.Subtract(-1, 0);
Assert.Fail("Should throw a NegativeParameterException");
}
catch (NegativeParameterException)
{ }
try
{
nResult = testCalc.Subtract(0, -1);
Assert.Fail("Should throw a NegativeParameterException");
}
catch (NegativeParameterException)
{ }
try
{
nResult = testCalc.Subtract(int.MinValue, int.MinValue);
Assert.Fail("Should throw a NegativeParameterException");
}
catch (NegativeParameterException)
{ }
}

2.

Escriba el esqueleto del mtodo que se necesitar en la clase Calculator.


public int Subtract(int numberToSubtract, int subtractFrom )
{
return 0;
}

3.

Compila y corra las pruebas. Como era de esperar fracaso la prueba TestSubtract. Estamos en la posicin de
escribir el cdigo para pasar la prueba.
public int Subtract(int numberToSubtract, int subtractFrom )
{
int result;
if (subtractFrom < 0 || numberToSubtract < 0 )
{
NegativeParameterException npEx = new NegativeParameterException();
throw npEx;
}
result = subtractFrom - numberToSubtract;
if (result < 0)
{
ResultOutOfRangeException rangeEx = new ResultOutOfRangeException();
throw rangeEx;
}
return result;

MATERIALES DE TRABAJO DE EVOLUCIN Y PRUEBAS DE SOFTWARE


}

4.

Compila y corral as pruebas. Ahora si paso.

Si observa cuidadosamente, notara que existe cdigo duplicado, la verificacin de los parmetros negativos se
repiten en los mtodos Add y Subtract, esto se puede extraer a un mtodo.

EJERCICIO 7: ESCRIBIR UNA PRUEBA Y LUEGO EXTRAER EL METODO


1.

Antes de cambiar el cdigo debemos escribir una prueba que valide la funcionalidad, por lo que tenemos extraer
que hace este nuevo cdigo (mtodo). Aada el mtodo TestCheckForNegativeNumbers a la clase CalcTests.
[TestMethod]
public void TestCheckForNegativeNumbers()
{
Console.Out.WriteLine("TestSubtract called");
Calculator testCalc = new Calculator();
try
{
testCalc.CheckForNegativeNumbers(0, 0);
}
catch (NegativeParameterException)
{
Assert.Fail("Zeros are not negative numbers");
}
try
{
testCalc.CheckForNegativeNumbers(1, 1);
}
catch (NegativeParameterException)
{
Assert.Fail("1's are not negative numbers");
}
try
{
testCalc.CheckForNegativeNumbers(
int.MaxValue, int.MaxValue);
}
catch (NegativeParameterException)
{
Assert.Fail("Max Vals are not negative numbers");
}
try
{
testCalc.CheckForNegativeNumbers(-1, -1);
Assert.Fail("-1's are negative numbers");
}
catch (NegativeParameterException)
{ }
try
{
testCalc.CheckForNegativeNumbers(
int.MinValue, int.MinValue);
Assert.Fail("Min Vals are negative numbers");
}
catch (NegativeParameterException)
{ }
}

2.

Aada el esqueleto del mtodo a la clase Calculator.


public void CheckForNegativeNumbers (int a, int b)
{ }

3.

Compila y corra las pruebas. Como se espera no pasa a prueba CheckForNegativeNumbers, por lo que
debemos escribir el siguiente cdigo.
public void CheckForNegativeNumbers (int a, int b)

MATERIALES DE TRABAJO DE EVOLUCIN Y PRUEBAS DE SOFTWARE


{
if (a < 0 || b < 0 )
{
NegativeParameterException npEx = new NegativeParameterException();
throw npEx;
}
}

4.

Recompila y corra las pruebas otra vez, ahora las pruebas son exitosas. Remplace el cdigo duplicado de los
mtodos Add y Subtract, de esta manera:
public int Add(int a, int b)
{
int result;
if (a < 0 || b < 0 )
{
NegativeParameterException npEx = new NegativeParameterException();
throw npEx;
}
.
.
.
}

A esto:
public int Add(int a, int b)
{
int result;
CheckForNegativeNumbers (a, b);
.
.
.
}

5.

Despus que ha reemplazado el cdigo con CheckForNegative, compila y corra las pruebas de nuevo para
asegurar que no hemos roto la funcionalidad ensayada en los mtodos Add y Subtract.

EJERCICIO 8:
1.

Todo est listo para conectar el mtodo Subtract a la interface de usuario. Asegrese que el proyecto regrese a
la interface grfica, cambiando la llamada del mtodo Application.Run con una nueva instancia del formulario. El
nombre de los botones de radio a aadir son AddRButton y SubtractRButton.

Figura 2. Interface de usuario aada botn de radio.

2.

Cambie el cdigo del botn Equals para el evento click.


private void EqualsButton_Click(object sender, System.EventArgs e)
{
try
{
Calculator calc = new Calculator();
if (AddRButton.Checked)
{
Result.Text = (calc.Add((int)NumberA.Value, (int)NumberB.Value).ToString());
}
else
{
Result.Text = (calc.Subtract((int)NumberB.Value, (int)NumberA.Value).ToString());
}
}

MATERIALES DE TRABAJO DE EVOLUCIN Y PRUEBAS DE SOFTWARE


catch (ResultOutOfRangeException)
{
Result.Text = "Out of Range";
}
catch (NegativeParameterException)
{
Result.Text = "Negatives not allowed";
}
}

3.

Compila y corra la aplicacin. Debe ser capaz de sumar y restar nmeros enteros positivos. No olvide de
modificar las propiedades del proyecto a Windows Application. Adems, de modificar el mtodo main.
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}

Note que el valor mnimo de los controles de NumericUpDown es cero, no se puede ingresar un nmero
negativo. Si quiere probar con negativos, necesita cambiar la propiedad Minimum de los controles.

EJERCICIO 9: EXTRAER LA FUNCIONALIDAD FUERA DE LA CAPA DE INTERFACE


1.

Comienza descomponiendo la decisin de que ejecutar. Crea un mtodo la clase Calculator para ejecutar ms
de un tipo de clculo, como: la suma o resta. Para esto crea un tipo enumerado, pero primero escribe la prueba
del nuevo mtodo.
[TestMethod]
public void TestCalculate()
{
Assert.AreEqual(2,testCalc.Calculate(1, CalcOperation.eAdd, 1),"Adding 1 to 1 failed");
Assert.AreEqual(0,testCalc.Calculate(1, CalcOperation.eSubtract, 1),"Subtracting 1 from 1 failed");
}

2.

Otra vez esto no compila. Para corregirlo cree el tipo enumerado en el fichero de la clase Calculator, pero fuera
de la clase.
public enum CalcOperation
{
eAdd = 0,
eSubtract = 1,
}

Aada el mtodo Calculate a la clase Calculator.


public int Calculate(int a, CalcOperation op, int b)
{
return 0;
}

3.

Compila y corra las pruebas. Falla en la sentencia de Assert.AreEqual.

4.

Modifica el mtodo Calculate.


public int Calculate(int a, CalcOperation op, int b)
{
int nResult = 0;
if (CalcOperation.eAdd == op)
{
nResult = Add(a, b);
}
else if (CalcOperation.eSubtract == op)
{
nResult = Subtract(b, a);
}
return nResult;
}

MATERIALES DE TRABAJO DE EVOLUCIN Y PRUEBAS DE SOFTWARE


5.

Compila y corra las pruebas. Ahora pasa. Modificamos el mtodo EqualsButton_Click del formulario.
private void EqualsButton_Click(object sender, System.EventArgs e)
{
try
{
Calculator calc = new Calculator();
CalcOperation op = new CalcOperation();
if (AddRButton.Checked)
{
op = CalcOperation.Add;
}
else
{
op = CalcOperation.Subtract;
}
Result.Text = calc.Calculate((int)NumberA.Value, op, (int)NumberB.Value).ToString();
}
catch (ResultOutOfRangeException)
{
Result.Text = "Out of Range";
}
catch (NegativeParameterException)
{
Result.Text = "Negatives not allowed";
}
}

6.

Aada los handlers de los botones de radio. Para eso define un campo en la clase Form.
private CalcOperation op = CalcOperation.eAdd;

Aada nuevos mtodos para los handlers de los botones de radio cuando se haga click.
private void AddRButton_CheckedChanged(object sender, System.EventArgs e)
{
if (AddRButton.Checked)
{
op = CalcOperation.eAdd;
}
}

private void SubtractRButton_CheckedChanged(object sender, System.EventArgs e)


{
if (SubtractRButton.Checked)
{
op = CalcOperation.eSubtract;
}
}

private void EqualsButton_Click(object sender, System.EventArgs e)


{
try
{
Calculator calc = new Calculator();
Result.Text = calc.Calculate((int)NumberA.Value, op, (int)NumberB.Value).ToString();
}
catch (ResultOutOfRangeException)
{
Result.Text = "Out of Range";
}
catch (NegativeParameterException)
{
Result.Text = "Negatives not allowed";
}
}

CONTENDIDO FINAL CALCTEST.CS


Se ha aadido el campo testCal de tipo Calculator; los mtodos: Initialize y Cleanup(). Luego se optimizado el cdigo.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

10

MATERIALES DE TRABAJO DE EVOLUCIN Y PRUEBAS DE SOFTWARE


using MiniCalc;
namespace CalcTest
{
[TestClass]
public class CalcTest
{
Calculator testCalc;
[TestInitialize]
public void Initialize()
{
testCalc = new Calculator();
}
[TestCleanup]
public void Cleanup()
{
testCalc = null;
}

[TestMethod]
public void TestAdd()
{
Console.Out.WriteLine("TestAddition called");
//test for case of zeros'
Assert.AreEqual(0, testCalc.Add(0, 0), "Adding 0 to 0 should produce 0");
//test that param ordering isn't important
Assert.AreEqual(1, testCalc.Add(1, 0), "Adding 1 to 0 should produce 1");
Assert.AreEqual(1, testCalc.Add(0, 1), "Adding 0 to 1 should produce 1");
//test for non zero case
Assert.AreEqual(3, testCalc.Add(1, 2), "Adding 1 to 2 should produce 3");
int nResult;
try
{
nResult = testCalc.Add(int.MaxValue, int.MaxValue);
Assert.Fail("Should throw a ResultOutofRangeException");
}
catch (ResultOutOfRangeException)
{
}
testCalc = null;
}
[TestMethod]
public void TestAddNegatives()
{
Console.Out.WriteLine("TestAddNegatives called");
int nResult;
try
{
nResult = testCalc.Add(-1, 0);
Assert.Fail("Should throw a NegativeParameterException");
}
catch (NegativeParameterException)
{}
try
{
nResult = testCalc.Add(0, -1);
Assert.Fail("Should throw a NegativeParameterException");
}
catch (NegativeParameterException)
{}
try
{
nResult = testCalc.Add(int.MinValue, int.MinValue);
Assert.Fail("Should throw a NegativeParameterException");
}
catch (NegativeParameterException)
{}

11

MATERIALES DE TRABAJO DE EVOLUCIN Y PRUEBAS DE SOFTWARE

testCalc = null;
}
[TestMethod]
public void TestSubtract()
{
Console.Out.WriteLine("TestSubtract called");
int nResult;
Assert.AreEqual(0, testCalc.Subtract(0, 0), "Subtracting 0 from 0 should produce 0");
Assert.AreEqual(1, testCalc.Subtract(0, 1), "Subtracting 0 from 1 should produce 1");
try
{
nResult = testCalc.Subtract(1, 0);
Assert.Fail("Subtracting 1 from 0 should throw a ResultOutofRangeException");
}
catch (ResultOutOfRangeException)
{}
Assert.AreEqual(0, testCalc.Subtract(int.MaxValue, int.MaxValue), "Subtracting max value from max value should produce 0");
try
{
nResult = testCalc.Subtract(-1, 0);
Assert.Fail("Should throw a NegativeParameterException");
}
catch (NegativeParameterException)
{}
try
{
nResult = testCalc.Subtract(0, -1);
Assert.Fail("Should throw a NegativeParameterException");
}
catch (NegativeParameterException)
{}
try
{
nResult = testCalc.Subtract(int.MinValue, int.MinValue);
Assert.Fail("Should throw a NegativeParameterException");
}
catch (NegativeParameterException)
{}
}
[TestMethod]
public void TestCheckForNegativeNumbers()
{
Console.Out.WriteLine("TestSubtract called");
try
{
testCalc.CheckForNegativeNumbers(0, 0);
}
catch (NegativeParameterException)
{
Assert.Fail("Zeros are not negative numbers");
}
try
{
testCalc.CheckForNegativeNumbers(1, 1);
}
catch (NegativeParameterException)
{
Assert.Fail("1's are not negative numbers");
}
try
{
testCalc.CheckForNegativeNumbers(
int.MaxValue, int.MaxValue);
}

12

MATERIALES DE TRABAJO DE EVOLUCIN Y PRUEBAS DE SOFTWARE


catch (NegativeParameterException)
{
Assert.Fail("Max Vals are not negative numbers");
}
try
{
testCalc.CheckForNegativeNumbers(-1, -1);
Assert.Fail("-1's are negative numbers");
}
catch (NegativeParameterException)
{}
try
{
testCalc.CheckForNegativeNumbers(
int.MinValue, int.MinValue);
Assert.Fail("Min Vals are negative numbers");
}
catch (NegativeParameterException)
{}
}
[TestMethod]
public void TestCalculate()
{
Console.Out.WriteLine("TestCalculate called");
Assert.AreEqual(2, testCalc.Calculate(1, CalcOperation.eAdd, 1), "Adding 1 to 1 failed");
Assert.AreEqual(0, testCalc.Calculate(1, CalcOperation.eSubtract, 1), "Subtracting 1 from 1 failed");
}
}
}

RESUMEN
En este conjunto de ejercicios se aplic los principios de desarrollo de basado en pruebas. A continuacin se resume
los pasos:
1.

Decida que funcionalidad se va ha de implementar, podra ser tambin corregir un defecto (bug).

2.

Escriba las pruebas del cdigo.

3.

Escriba el esqueleto del cdigo que nos permita compilar.

4.

Compila y corra las pruebas (debe fallar).

5.

Complete el esqueleto de manera que pase las pruebas.

6.

Compila y corra las pruebas. Si las pruebas fracasan, vuelva al paso 5.

7.

Simplifique el cdigo donde sea posible; esto puede involucrar los pasos del 1 al 6 de nuevo.

8.

Esto a terminado. Tome un descanso y comience de nuevo.

Cada paso en el ciclo es un simple hacer y al final del ciclo se habr aadido una unidad de la funcionalidad (o
arreglado un defecto) que pasaron las pruebas. Puede programar otras unidades de la funcionalidad con ms la
confianza.

CUESTIONARIO
1.

Elabore un mapa mental del procedimiento utilizado para implementar el proyecto minicalc.

2.

Realice un comentario sobre el procedimiento utilizado para implementar el proyecto minicalc.

13

S-ar putea să vă placă și