Last active
August 29, 2015 13:57
-
-
Save chbaranowski/9672582 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.junit.Assert.*; | |
import org.junit.*; | |
public class CalcTest { | |
Calc calc; | |
@Before | |
public void setup() { | |
System.out.println("1. Setup"); | |
calc = new Calc(); | |
} | |
@Test | |
public void sum() { | |
System.out.println("2. Exercise - sum()"); | |
int sum = calc.sum(); | |
System.out.println("3. Verfiy - sum()"); | |
assertEquals(0, sum); | |
} | |
@Test | |
public void addFiveFive() { | |
System.out.println("2. Exercise - testAddFiveFive()"); | |
calc.add(5); | |
calc.add(5); | |
int sum = calc.sum(); | |
System.out.println("3. Verfiy - testAddFiveFive()"); | |
assertEquals(10, sum); | |
} | |
// verify via JUnit runner, | |
// checks the expected IllegalStateException | |
@Test(expected = IllegalStateException.class) | |
public void addMinusOne() { | |
System.out.println("2. Exercise - add Minus One"); | |
calc.add(-1); | |
} | |
@After | |
public void teardown() { | |
System.out.println("4. Teardown"); | |
calc = null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment