non ho idea di come testare e stavo seguendo un tutorial.I Sto cercando di eseguire:eventi test non sono stati ricevuti - Android Studio
package name.company.sunshine.app.data;
import android.test.AndroidTestCase;
public class TestPractice extends AndroidTestCase {
/*
This gets run before every test.
*/
@Override
protected void setUp() throws Exception {
super.setUp();
}
public void testThatDemonstratesAssertions() throws Throwable {
int a = 5;
int b = 3;
int c = 5;
int d = 10;
assertEquals("X should be equal", a, c);
assertTrue("Y should be true", d > a);
assertFalse("Z should be false", a == b);
if (b > d) {
fail("XX should never happen");
}
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
}
}
ma ho da qualche parte in basso a sinistra, nella console Test events were not received
. Che cosa sto facendo di sbagliato ? Devo eseguire qualcos'altro?
Solo un po ', hai provato a rimuovere l'eccezione 'getta' dalla funzione di test? Prova a gestirlo nella tua funzione. Non ho dimestichezza con Unit Testing su Android, ma nei test della junit standard, l'eccezione deve essere esplicitamente dichiarata al tester dell'unità. '@Test (expected = Exception.class)' –
Non ce l'ho, ma questo è esattamente ciò che stanno facendo nel tutorial e per qualche motivo non ottiene 'Gli eventi di test non sono stati ricevuti '. Cosa dovrei rimuovere e dove dovrei aggiungerlo? –
Provare a modificare questa riga: 'public void testThatDemonstratesAssertions() genera Throwable {' a questo: 'public void testThatDemonstratesAssertions() {' e gestisce l'eccezione nel caso di test, se applicabile. Che tutorial segui? –