Advanced Programming
SUT • Spring 2019
Java Programming Language
Principles of Object Oriented Programming
Characteristics of objects
Encapsulation
Objects in memory
References
Heap
Stack
Parameter Passing
Software Quality
Characteristic of a good software
Test
Unit Testing
Refactoring
The producer should ensure about the quality of the products
Quality Control
Any business, any product
public class BusinessTest extends TestCase {
public void testSort(){
int[] list = {3, 2, 5, 7, 6, 1, 3};
Business.sort(list);
int[] sortedList = {1, 2, 3, 3, 5, 6, 7};
for (int i = 0; i < sortedList.length; i++){
assertEquals(list[i], sortedlist[i]);
}
}
}
public class Testing {
@Test
public void testNormal() {
int[] array = {3, 2, 1, 4};
int[] sorted = {1, 2, 3, 4};
Business.sort(array);
for (int i = 0; i < sorted.length; i++) {
Assert.assertEquals(sorted[i], array[i]);
}
}
@Test
public void testEmptyArray() {
int[] array = {};
try {
Business.sort(array);
} catch (Exception e) {
Assert.fail();
}
Assert.assertEquals(array.length, 0);
}
}
@Test
public void theTestMax() {
System.out.println(" testMax()");
assertEquals(Business.max(list), 7);
}
@Test
public void theTestMin() {
System.out.println(" testMin()");
assertEquals(Business.min(list), 1);
}
@Before
public void theTestMax() {
System.out.println(" setUp()");
}
@After
public void theTestMax() {
System.out.println(" tearDown()\n");
}