DISEÑO Y PRUEBAS DE UNIDAD<br />INTEGRANTES:<br />ÁLVAREZ GONZÁLEZ ÁLVARO<br />ÁNGEL AVILES MÓNICA<br />GÓMEZ LÓPEZ RODOLF...
DISEÑO<br />
BIBLIOGRAFÍA<br />http://goo.gl/kU0I5<br />http://goo.gl/6pcDy<br />http://goo.gl/GDa9Z<br />http://goo.gl/9Dzvt<br />http...
Clase operación<br />public class Operacion {<br />    static intCalcular (int p , int n){<br />int m ;<br />    if(n==0){...
Midlet<br />publicclassMidletextendsMIDletimplementsCommandListener {<br />private final Displaydisplay = Display.getDispl...
publicvoidstartApp() {<br />display.setCurrent(frmCalculo);<br />    }<br />publicvoidpauseApp() {<br />    }<br />publicv...
privatevoid suma() {<br />int a = Integer.parseInt(txtP.getString().trim());<br />int b= Integer.parseInt(txtN.getString()...
Pruebas de unidad<br />publicclassOperacionTest {<br />publicOperacionTest() {<br />    }<br />    @BeforeClass<br />publi...
@Test<br />publicvoidtestCalcular() {<br />System.out.println("Calcular");<br />assertEquals(0,Operacion.Calcular(1, 1));<...
Upcoming SlideShare
Loading in …5
×

Diseño y pruebas de unidad

305 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
305
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Diseño y pruebas de unidad

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

×