Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lab4;
- import static org.junit.Assert.*;
- import static org.junit.jupiter.api.Assertions.assertTrue;
- import org.junit.Before;
- import org.junit.Test;
- public class MyCarTest {
- @Before
- public void setUp() throws Exception {
- }
- @Test
- public void testMyCar() throws CreationException {
- MyCar car1 = new MyCar("30 5 fiat");
- }
- @Test (expected = CreationException.class)
- public void testMyCarFail() throws CreationException {
- MyCar car2 = new MyCar("0 2 fiat");
- }
- @Test
- public void testMyCarString() {
- }
- @Test
- public void testTankIt() throws FullTankException, CreationException{
- MyCar car3 = new MyCar("30 5 fiat");
- car3.tankIt(0);
- }
- @Test (expected = FullTankException.class)
- public void testTankItFail() throws FullTankException, CreationException{
- MyCar car4 = new MyCar("30 5 fiat");
- car4.tankIt(100);
- }
- @Test
- public void testStartTrip() throws LowFuelException, CreationException {
- MyCar car5 = new MyCar("45 5 bmw");
- car5.startTrip(100.0);
- }
- @Test (expected = LowFuelException.class)
- public void testStartTripFail() throws LowFuelException, CreationException {
- MyCar car6 = new MyCar("45 5 bmw");
- car6.startTrip(1000.0);
- }
- @Test
- public void testGetMileage() throws CreationException {
- MyCar car7 = new MyCar("47 10 Volvo");
- double mil = car7.getMileage();
- assertTrue(mil==0.0);
- }
- @Test
- public void testGetMileageFail() throws CreationException {
- MyCar car8 = new MyCar("47 10 fiat");
- double mil = car8.getMileage();
- assertFalse(mil==1.0);
- }
- @Test
- public void testGetLastTripDistance() throws CreationException, LowFuelException {
- MyCar car9 = new MyCar("47 10 fiat");
- car9.startTrip(100.0);
- assertTrue(car9.getLastTripDistance()==100.00);
- }
- @Test
- public void testGetFuelLevel() throws CreationException {
- MyCar car10 = new MyCar("45 9 bmw");
- assertTrue(car10.getFuelLevel()==45);
- }
- @Test
- public void testToString() throws CreationException {
- MyCar car11 = new MyCar("45 9 bmw");
- System.out.println(car11.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement