Created by Wig Cheng (鄭元誠) and Chang Yu-heng (張昱珩)
2014-07-07
Coding Unit Test
=> Test-driven development (TDD)
An unit can be viewed as the smallest testable part of an application
Production Code
Test Code
public int sum(int x, int y) {
return x + y;
}
public void testSum() {
int i = sum(1, 2);
assertEquals(i, 3);
}
The testing code is dedicated for the implementation
Pros:
Cons:
The testing code is dedicated for the interface
Pros:
Production Code
Test Code
public int max(int x, int y) {
if (x > y)
return x;
else
return y;
}
public void testMax() {
int i = max(2, 1);
assertEquals(i, 2);
i = max(6, 9);
assertEquals(i, 99);
}
Wouldn’t it be nice to run your Android tests directly from inside your IDE?
Automated functional UI test cases
Capture and replay the test cases