Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 2.08 KB | None | 0 0
  1. package lab4;
  2.  
  3. import static org.junit.Assert.*;
  4. import static org.junit.jupiter.api.Assertions.assertTrue;
  5.  
  6. import org.junit.Before;
  7. import org.junit.Test;
  8.  
  9. public class MyCarTest {
  10.  
  11.     @Before
  12.     public void setUp() throws Exception {
  13.     }
  14.  
  15.     @Test
  16.     public void testMyCar() throws CreationException {
  17.         MyCar car1 = new MyCar("30 5 fiat");
  18.     }
  19.    
  20.     @Test (expected = CreationException.class)
  21.     public void testMyCarFail() throws CreationException {
  22.         MyCar car2 = new MyCar("0 2 fiat");
  23.     }
  24.  
  25.     @Test
  26.     public void testMyCarString() {
  27.        
  28.     }
  29.  
  30.     @Test
  31.     public void testTankIt() throws FullTankException, CreationException{
  32.         MyCar car3 = new MyCar("30 5 fiat");
  33.         car3.tankIt(0);
  34.     }
  35.    
  36.     @Test (expected = FullTankException.class)
  37.     public void testTankItFail() throws FullTankException, CreationException{
  38.         MyCar car4 = new MyCar("30 5 fiat");
  39.         car4.tankIt(100);
  40.     }
  41.  
  42.     @Test
  43.     public void testStartTrip() throws LowFuelException, CreationException {
  44.         MyCar car5 = new MyCar("45 5 bmw");
  45.         car5.startTrip(100.0);
  46.     }
  47.    
  48.     @Test (expected = LowFuelException.class)
  49.     public void testStartTripFail() throws LowFuelException, CreationException {
  50.         MyCar car6 = new MyCar("45 5 bmw");
  51.         car6.startTrip(1000.0);
  52.     }
  53.  
  54.     @Test
  55.     public void testGetMileage() throws CreationException {
  56.         MyCar car7 = new MyCar("47 10 Volvo");
  57.         double mil = car7.getMileage();
  58.         assertTrue(mil==0.0);
  59.     }
  60.    
  61.     @Test
  62.     public void testGetMileageFail() throws CreationException {
  63.         MyCar car8 = new MyCar("47 10 fiat");
  64.         double mil = car8.getMileage();
  65.         assertFalse(mil==1.0);
  66.     }
  67.  
  68.     @Test
  69.     public void testGetLastTripDistance() throws CreationException, LowFuelException {
  70.         MyCar car9 = new MyCar("47 10 fiat");
  71.         car9.startTrip(100.0);
  72.         assertTrue(car9.getLastTripDistance()==100.00);
  73.     }
  74.  
  75.     @Test
  76.     public void testGetFuelLevel() throws CreationException {
  77.         MyCar car10 = new MyCar("45 9 bmw");
  78.         assertTrue(car10.getFuelLevel()==45);
  79.     }
  80.  
  81.     @Test
  82.     public void testToString() throws CreationException {
  83.         MyCar car11 = new MyCar("45 9 bmw");
  84.         System.out.println(car11.toString());
  85.        
  86.     }
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement