2013/11/8 Manlio Perillo <manlio.peri...@gmail.com> > > > Allora no, che io sappia nose ed PyUnit non si comportano come le nuove > versioni di JUnit. > > Capito.
> Puoi postare un esempio di come si fa in JUnit? > Ecco qua. ******** SuperTest.java ******** import org.junit.Before; import org.junit.Test; public abstract class SuperTest { @Before public void init() throws Exception { System.out.println("I'm a Super init"); } @Before public void anotherInit() throws Exception { System.out.println("I'm another Super init"); } @Test public void just_a_test() throws Exception { System.out.println("Just a test in the superclass"); } @Test public void yet_another_test() throws Exception { System.out.println("Yet another test in the superclass"); } } ******** Subest.java ******** import org.junit.Before; import org.junit.Test; public class SubTest extends SuperTest { @Before public void subInit() throws Exception { System.out.println("I'm a Sub init"); } @Before public void anotherSubInit() throws Exception { System.out.println("I'm another Sub init"); } @Test public void more_testing() throws Exception { System.out.println("more testing in the subclass"); } @Test public void little_more_testing() throws Exception { System.out.println("little more testing in the subclass"); } } ******** stdout dell'esecuzione ******** I'm another Super init I'm a Super init I'm another Sub init I'm a Sub init more testing in the subclass I'm another Super init I'm a Super init I'm another Sub init I'm a Sub init little more testing in the subclass I'm another Super init I'm a Super init I'm another Sub init I'm a Sub init Just a test in the superclass I'm another Super init I'm a Super init I'm another Sub init I'm a Sub init Yet another test in the superclass Notare che: - Non sei costretto ad avere una superclasse astratta, e' solo comune fare cosi' (non mi dilungo a spiegare perche', non sarebbe OT) - L'ordine di esecuzione dei @Before di una classe e' indeterminato, ma l'ordine tra classi e' determinato - Le teardown si comportano alla stessa maniera al contrario (cioe' prima le sottoclassi e poi le superclassi, l'annotazione per loro e' ovviamente @After) Ciao Giuliano -- Piergiuliano Bossi Blog: http://thinkingbox.wordpress.com/ Twitter: http://twitter.com/thinkingbox (English) Twitter: http://twitter.com/scatolapensante (Italiano) Google+: https://plus.google.com/u/0/108187981162465525118
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python