|
| 1 | +package com.baeldung.inheritance; |
| 2 | + |
| 3 | +import com.baeldung.inheritance.*; |
| 4 | + |
| 5 | +import junit.framework.Test; |
| 6 | +import junit.framework.TestCase; |
| 7 | +import junit.framework.TestSuite; |
| 8 | + |
| 9 | +public class AppTest extends TestCase { |
| 10 | + |
| 11 | + public AppTest(String testName) { |
| 12 | + super( testName ); |
| 13 | + } |
| 14 | + |
| 15 | + public static Test suite() { |
| 16 | + return new TestSuite(AppTest.class); |
| 17 | + } |
| 18 | + |
| 19 | + @SuppressWarnings("static-access") |
| 20 | + public void testStaticMethodUsingBaseClassVariable() { |
| 21 | + Car first = new ArmoredCar(); |
| 22 | + assertEquals("Car", first.msg()); |
| 23 | + } |
| 24 | + |
| 25 | + @SuppressWarnings("static-access") |
| 26 | + public void testStaticMethodUsingDerivedClassVariable() { |
| 27 | + ArmoredCar second = new ArmoredCar(); |
| 28 | + assertEquals("ArmoredCar", second.msg()); |
| 29 | + } |
| 30 | + |
| 31 | + public void testAssignArmoredCarToCar() { |
| 32 | + Employee e1 = new Employee("Shreya", new ArmoredCar()); |
| 33 | + assertNotNull(e1.getCar()); |
| 34 | + } |
| 35 | + |
| 36 | + public void testAssignSpaceCarToCar() { |
| 37 | + Employee e2 = new Employee("Paul", new SpaceCar()); |
| 38 | + assertNotNull(e2.getCar()); |
| 39 | + } |
| 40 | + |
| 41 | + public void testBMWToCar() { |
| 42 | + Employee e3 = new Employee("Pavni", new BMW()); |
| 43 | + assertNotNull(e3.getCar()); |
| 44 | + } |
| 45 | + |
| 46 | +} |
0 commit comments