Unit Testing and Coverage
Unit Testing and Coverage
Unit Testing and Coverage
assertEquals(expected, actual)
assertEquals(message, expected, actual)
assertEquals(expected, actual, delta)
assertEquals(message, expected, actual, delta)
assertFalse(condition)
assertFalse(message, condition)
Assert(Not)Null(object)
Assert(Not)Null(message, object)
Assert(Not)Same(expected, actual)
Assert(Not)Same(message, expected, actual)
assertTrue(condition)
assertTrue(message, condition)
Junit Methods – Java annotations
@BeforeClass // Run before all tests in class
public static void setUpClass() throws Exception {}
@Test
public void testMain() {
http://www.cavdar.net/2008/07/21/junit-4-in-60-seconds/
Junit with Netbeans
Note: If this option doesn’t exist use
New File->Other->Junit->Test for
1. New File existing class
http://junit.sourceforge.net/doc/testinfected/testing.htm
(older)
Lines of code coverage analysis
If you don't see Netbeans Beta in the list on Settings, add the
following source for plugins:
Netbeans Beta
http://updates.netbeans.org/netbeans/updates/6.8/uc/final/beta/
catalog.xml.gz
How do you you combine
coverage with traditional system
test scripts?
Traditional system testing uses scripts
- 1. Enter salary
- 2. Enter number of dependents
- 3. Click “Calculate Taxes” button
- …