REMEMBER JAVA

MINTE9
2REMEMBER




JUnit

p7 In unit testing the programmer writes code to verify units of code.
 CodeCopy
/**
 * JUnit 3-style: 
*/

import junit.framework.TestCase;

public class AppTest extends TestCase { // extend TestCase

    public void testMymethod() { // method must start with 'test'
       fail("Not implemented yet");
    }    
}
... 9 lines
˄˄˄
The methods that start with @Test annotation are executed as tests.
 CodeCopy
/**
 * JUnit 4-style:
 * 
 * You might need to add hamcrest to Referenced Libraries
*/

import org.junit.Test;
import static org.junit.Assert.fail;

public class AppTest {

    @Test public void mymethod() { // add @Test annotation
       fail("Not implemented yet");
    }    
}
... 12 lines
˄˄˄

Questions    
CARD
63
63

        A B C D E F
🔔
1/1