Diseño y pruebas de unidad
Upcoming SlideShare
Loading in...5
×
 

Diseño y pruebas de unidad

on

  • 305 views

 

Statistics

Views

Total Views
305
Views on SlideShare
305
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Diseño y pruebas de unidad Diseño y pruebas de unidad Presentation Transcript

  • DISEÑO Y PRUEBAS DE UNIDAD
    INTEGRANTES:
    ÁLVAREZ GONZÁLEZ ÁLVARO
    ÁNGEL AVILES MÓNICA
    GÓMEZ LÓPEZ RODOLFO
    GUZMÁN ZANABRIA ANA LAURA
    PÉREZ MELO ALAN GIOVANNI
    SUAZO REZA DAVID
  • DISEÑO
  • BIBLIOGRAFÍA
    http://goo.gl/kU0I5
    http://goo.gl/6pcDy
    http://goo.gl/GDa9Z
    http://goo.gl/9Dzvt
    http://goo.gl/gIMBh
    http://goo.gl/qy13L
    http://www.junit.org/
    http://goo.gl/hUrp3
    http://goo.gl/WKWzp
  • Clase operación
    public class Operacion {
    static intCalcular (int p , int n){
    int m ;
    if(n==0){
    m=123456789;
    }
    else{ m= ((p - (3*n)) / (p - n + 4));
    }
    return m;
    }
    }
  • Midlet
    publicclassMidletextendsMIDletimplementsCommandListener {
    private final Displaydisplay = Display.getDisplay(this);
    private final TextFieldtxtP = new TextField("P:","",10,TextField.NUMERIC);
    private final TextFieldtxtN = new TextField("N:","",10,TextField.NUMERIC);
    private final StringItemtxtres = new StringItem("M=", "");
    private final CommandcmdSalir = new Command ("salir", Command.EXIT,1);
    private final CommandcmdSuma = new Command ("Calcular",Command.SCREEN,1);
    private final FormfrmCalculo = new Form("Operacion:");
    {
    frmCalculo.append(txtP);
    frmCalculo.append(txtN);
    frmCalculo.append(txtres);
    frmCalculo.addCommand(cmdSuma);
    frmCalculo.addCommand(cmdSalir);
    frmCalculo.setCommandListener((CommandListener)this);
    }
  • publicvoidstartApp() {
    display.setCurrent(frmCalculo);
    }
    publicvoidpauseApp() {
    }
    publicvoiddestroyApp(booleanunconditional) {
    }
    publicvoidcommandAction(Command c, Displayable d) {
    if(d == frmCalculo && c==cmdSalir){
    salir();
    }elseif(d== frmCalculo && c==cmdSuma){
    suma();
    }
    }
    privatevoid salir() {
    destroyApp(true);
    notifyDestroyed();
    }
  • privatevoid suma() {
    int a = Integer.parseInt(txtP.getString().trim());
    int b= Integer.parseInt(txtN.getString().trim());
    int resultado=Operacion.Calcular(a, b);
    if(resultado==123456789){
    txtres.setText("error");
    }else
    txtres.setText(""+resultado);
    }
    }
  • Pruebas de unidad
    publicclassOperacionTest {
    publicOperacionTest() {
    }
    @BeforeClass
    publicstaticvoidsetUpClass() throwsException {
    }
    @AfterClass
    publicstaticvoidtearDownClass() throwsException {
    }
    @Before
    publicvoidsetUp() {
    }
    @After
    publicvoidtearDown() {
    }
  • @Test
    publicvoidtestCalcular() {
    System.out.println("Calcular");
    assertEquals(0,Operacion.Calcular(1, 1));
    assertEquals(1,Operacion.Calcular(5, -8));
    assertEquals(-7,Operacion.Calcular(4, 6));
    assertEquals(7,Operacion.Calcular(-4, 1));
    assertEquals(2,Operacion.Calcular(1, -9));
    assertTrue(Operacion.Calcular(1, 1)== 0);
    //caso erroneo
    assertFalse(Operacion.Calcular(1, 1)== 2);
    assertFalse(Operacion.Calcular(1, 1)== 3);
    }
    }