Commit 8f7b8a32 by Patryk Czarnik

setUp

parent c71302ec
...@@ -6,27 +6,29 @@ import org.junit.jupiter.api.BeforeEach; ...@@ -6,27 +6,29 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
class KontoTest { class KontoTest {
private Konto konto;
@BeforeEach @BeforeEach
void setUp() throws Exception { void setUp() {
// metoda wykona się bezpośrednio przed każdy testem
// istnieje też @AfterEach tearDown() - wykonuje się po każdym teście
// Zazwyczaj w setUp przygotowuje się wspólne dane potrzebne przed każdym testem, taki stan początkowy (w literaturze: "fixture").
konto = new Konto(123, "Ala Kowalska", 1000);
} }
@Test @Test
void testToString() { void testToString() {
Konto konto = new Konto(123, "Ala Kowalska", 1000);
assertEquals("Konto nr 123, wł. Ala Kowalska, saldo 1000", konto.toString()); assertEquals("Konto nr 123, wł. Ala Kowalska, saldo 1000", konto.toString());
} }
@Test @Test
void testWplata() { void testWplata() {
Konto konto = new Konto(123, "Ala Kowalska", 1000);
konto.wplata(300); konto.wplata(300);
assertEquals(1300, konto.getSaldo()); assertEquals(1300, konto.getSaldo());
} }
@Test @Test
void testWyplata() { void testWyplata() {
Konto konto = new Konto(123, "Ala Kowalska", 1000);
konto.wyplata(200); konto.wyplata(200);
assertEquals(800, konto.getSaldo()); assertEquals(800, konto.getSaldo());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment