Skip to content

Commit 4862e68

Browse files
committed
complete
1 parent a61b55d commit 4862e68

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

  • unit-testing/chapter-example/car-example/src/test/java/org/launchcode

unit-testing/chapter-example/car-example/src/test/java/org/launchcode/CarTest.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
package org.launchcode;
22

3-
import static org.junit.jupiter.api.Assertions.*;
3+
import org.junit.jupiter.api.BeforeEach;
4+
import org.junit.jupiter.api.Test;
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
46

57
class CarTest {
8+
Car test_car; // Declare the Car object here
9+
10+
@BeforeEach
11+
public void createCarObject() {
12+
// Initialize the Car object before each test
13+
test_car = new Car("Toyota", "Prius", 10, 50);
14+
}
15+
616
//TODO: add emptyTest so we can configure our runtime environment (remove this test before pushing to your personal GitLab account)
17+
@Test
18+
public void emptyTest() {
19+
assertEquals(10, 10, .001);
20+
}
21+
722
//TODO: constructor sets gasTankLevel properly
23+
@Test
24+
public void testInitialGasTank() {
25+
assertEquals(10, test_car.getGasTankLevel(), .001);
26+
}
27+
828
//TODO: gasTankLevel is accurate after driving within tank range
929
//TODO: gasTankLevel is accurate after attempting to drive past tank range
1030
//TODO: can't have more gas than tank size, expect an exception

0 commit comments

Comments
 (0)