My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.chuidiang.ejemplos.junit45;

import static org.junit.Assert.assertEquals;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.chuidiang.ejemplos.Suma;

/**
* Una clase de tests con junit 4.5 El metodo que queramos que se ejecute antes
* de hacer el test, debemos anotarlo con @Before. El que queramos que se
* ejecute despues de los test debemos anotarlo con @After. Los metodos de test
* con @Test. Para poder usar los metodos assert, debemos hacer un
*
* import static org.junit.Assert.*;
*
* @author Chuidiang
*/
public class TestSuma {

private Suma suma;

@Test
public void aVerSiIncrementaBien() {
assertEquals("Test incrementa", 2.0, suma.incrementa(1.0), 1e-6);
}

@Test
public void aVerSiSumaBien() {
assertEquals("Test suma", 2.0, suma.getSuma(1.0, 1.0), 1e-6);
}

@Before
public void paraEjecutarAntes() throws Exception {
suma = new Suma();
}

@After
public void paraEjecutarDespues() throws Exception {
// Fin de test. Aqui liberar recursos o borrar rastros del test
}

}

Change log

r54 by chuidiang on May 7, 2009   Diff
[No log message]
Go to: 
Project members, sign in to write a code review

Older revisions

r52 by chuidiang on May 7, 2009   Diff
Version con junit 3.8.1
All revisions of this file

File info

Size: 1170 bytes, 45 lines
Powered by Google Project Hosting