@before ne fonctionne pas
Bonjour,
je commence tout juste avec l'utilisation de Junit, j'ai vu qu'il était possible d'appeler des méthodes avant les test via l'annotation @before or quand je l'utilise et que je lance mon test, le test est validé mais junit ne rentre pas dans la méthode correspondant au @before
Voici mon code:
Code:
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
|
import org.junit.*;
import org.junit.Test;
import org.junit.BeforeClass;
import org.junit.Ignore;
import junit.framework.*;
import static org.junit.Assert.*;
public class TestConstantPool extends junit.framework.TestCase {
@Before public void AvantTest(){
System.out.println("avant le test");
ConstantPool cp = new ConstantPool();
}
@Test public void testGetCp(){
ConstantPool cp = new ConstantPool();
cp.addCpUtf8("test");
byte test [] = cp.getCp();
assertEquals(7,test.length);
}
public static void main (String []args){
junit.textui.TestRunner.run(TestConstantPool.class);
}
} |
Affichage console:
[alexis@bc_8 Mon_projet]$ java TestConstantPool
.
Time: 0.002
OK (1 test)
[alexis@bc_8 Mon_projet]$
Pourriez vous m'éclairer sur la marche à suivre?