lots of exercises in java... from https://github.com/exercism/java

PrimeCalculatorTest.java 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import org.junit.Before;
  2. import org.junit.Ignore;
  3. import org.junit.Rule;
  4. import org.junit.Test;
  5. import org.junit.rules.ExpectedException;
  6. import static org.hamcrest.CoreMatchers.*;
  7. import static org.junit.Assert.*;
  8. public class PrimeCalculatorTest {
  9. private PrimeCalculator primeCalculator;
  10. @Before
  11. public void setup() {
  12. primeCalculator = new PrimeCalculator();
  13. }
  14. @Rule
  15. public ExpectedException thrown = ExpectedException.none();
  16. @Test
  17. public void testFirstPrime() {
  18. assertThat(primeCalculator.nth(1), is(2));
  19. }
  20. @Ignore("Remove to run test")
  21. @Test
  22. public void testSecondPrime() {
  23. assertThat(primeCalculator.nth(2), is(3));
  24. }
  25. @Ignore("Remove to run test")
  26. @Test
  27. public void testSixthPrime() {
  28. assertThat(primeCalculator.nth(6), is(13));
  29. }
  30. @Ignore("Remove to run test")
  31. @Test
  32. public void testBigPrime() {
  33. assertThat(primeCalculator.nth(10001), is(104743));
  34. }
  35. @Ignore("Remove to run test")
  36. @Test
  37. public void testUndefinedPrime() {
  38. thrown.expect(IllegalArgumentException.class);
  39. primeCalculator.nth(0);
  40. }
  41. }