MainApplicationTest.java 993B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import static org.junit.Assert.*;
  2. import org.junit.After;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. import org.junit.Assert;
  6. public class MainApplicationTest
  7. {
  8. MainApplication main = new MainApplication();
  9. Pet petCaller = new Pet();
  10. @Test
  11. public void testSpeakDog(){
  12. //when
  13. petCaller.setTypes("Dog");
  14. petCaller.setName("Sparky");
  15. petCaller.setSpeak("Woof");
  16. //expected
  17. String expected = "Dog : Sparky says: Woof";
  18. //actual
  19. String actual = main.
  20. Assert.assertEquals(expected, actual);
  21. }
  22. @Test2
  23. public void testSpeakFish(){
  24. //when
  25. petCaller.setTypes("Fish");
  26. petCaller.setName("Zach");
  27. petCaller.setSpeak("...");
  28. //expected
  29. String expected = "Fish : Zach says: ...";
  30. //actual
  31. String actual = main.
  32. Assert.assertEquals(expected, actual);
  33. }
  34. }