generated from ohjelmointi2/gradle-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVehicleTest.java
More file actions
51 lines (41 loc) · 1.6 KB
/
VehicleTest.java
File metadata and controls
51 lines (41 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package inheritance.webshop;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
public class VehicleTest {
// The object under test
private Vehicle fiesta = new Vehicle("My trusty old car",
"Red and shiny with little rust spots", 700.0, "Ford",
"Fiesta", 2010);
@Test
void vehicleClassMustInheritProductClass() {
assertTrue((Object) fiesta instanceof Product, "The Vehicle class must inherit the Product class");
}
@Test
void methodsFromSuperClassMustReturnCorrectValues() {
ProductTest.checkMethod(fiesta, "getTitle", "My trusty old car");
ProductTest.checkMethod(fiesta, "getDescription", "Red and shiny with little rust spots");
ProductTest.checkMethod(fiesta, "getPrice", 700.0);
}
@Test
void manufacturerMustBePresentAndReturnTheCorrectValue() {
ProductTest.checkMethod(fiesta, "getManufacturer", "Ford");
}
@Test
void modelMustBePresentAndReturnTheCorrectValue() {
ProductTest.checkMethod(fiesta, "getModel", "Fiesta");
}
@Test
void yearMustBePresentAndReturnTheCorrectValue() {
ProductTest.checkMethod(fiesta, "getYear", 2010);
}
@Test
void toStringMustContainAllFields() {
String str = fiesta.toString();
assertTrue(str.contains("My trusty old car"));
assertTrue(str.contains("Red and shiny with little rust spots"));
assertTrue(str.contains("700"));
assertTrue(str.contains("Ford"));
assertTrue(str.contains("Fiesta"));
assertTrue(str.contains("2010"));
}
}