FizzBuzzTest.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import static org.junit.Assert.*;
  2. import org.junit.After;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. /**
  6. * The test class FizzBuzzTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. public class FizzBuzzTest
  12. {
  13. @Test
  14. public void testFive() {
  15. Integer input = 5;
  16. FizzBuzz fb = new FizzBuzz(input);
  17. boolean fizz = fb.getFizz();
  18. boolean buzz = fb.getBuzz();
  19. boolean fizzBuzz = fb.getFizzBuzz();
  20. assertFalse(fizz); // multiple of 3
  21. assertTrue(buzz); // multiple of 5
  22. assertFalse(fizzBuzz); // multiple of 15
  23. }
  24. @Test
  25. public void testThree() {
  26. Integer input = 3;
  27. FizzBuzz fb = new FizzBuzz(input);
  28. boolean fizz = fb.getFizz();
  29. boolean buzz = fb.getBuzz();
  30. boolean fizzBuzz = fb.getFizzBuzz();
  31. assertTrue(fizz); // multiple of 3
  32. assertFalse(buzz); // multiple of 5
  33. assertFalse(fizzBuzz); // multiple of 15
  34. }
  35. @Test
  36. public void testTen() {
  37. Integer input = 10;
  38. FizzBuzz fb = new FizzBuzz(input);
  39. boolean fizz = fb.getFizz();
  40. boolean buzz = fb.getBuzz();
  41. boolean fizzBuzz = fb.getFizzBuzz();
  42. assertFalse(fizz); // multiple of 3
  43. assertTrue(buzz); // multiple of 5
  44. assertFalse(fizzBuzz); // multiple of 15
  45. }
  46. @Test
  47. public void testSix() {
  48. Integer input = 6;
  49. FizzBuzz fb = new FizzBuzz(input);
  50. boolean fizz = fb.getFizz();
  51. boolean buzz = fb.getBuzz();
  52. boolean fizzBuzz = fb.getFizzBuzz();
  53. assertTrue(fizz); // multiple of 3
  54. assertFalse(buzz); // multiple of 5
  55. assertFalse(fizzBuzz); // multiple of 15
  56. }
  57. @Test
  58. public void testFifteen() {
  59. Integer input = 15;
  60. FizzBuzz fb = new FizzBuzz(input);
  61. boolean fizz = fb.getFizz();
  62. boolean buzz = fb.getBuzz();
  63. boolean fizzBuzz = fb.getFizzBuzz();
  64. assertTrue(fizz); // multiple of 3
  65. assertTrue(buzz); // multiple of 5
  66. assertTrue(fizzBuzz); // multiple of 15
  67. }
  68. }