??????????:
????setUp()??tearDown()??setUpBeforeClass()??tearDownAfterClass()??????????????????
????@Before??@BeforeClass??@After??@AfterClass????????
??????Junit4?????????????????????????????????????????????????????????????????????????????????????????????
????assertTrue(...)        ??????????true
????assertFalse(...)    ??????????false
????assertNull(...)        ???null?
????assertNotNull(...)    ????null???
????assertSame(...)        ???==???????true?????????????
????AssertNotSame(...)    ???==???????false
????assertEquals(...)    ????????equals()??????????true
???????????
package com.lee;
import org.junit.Test;
public class junitDemo {
public static void main(String[] args) {
}
public static int sum(){
int x = 5;
int y = 10;
return x + y;
}
}
package com.lee;
import org.junit.*;
public class junitDemoTest {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void testSum() {
int max = junitDemo.sum();
Assert.assertSame(15?? max);
Assert.assertEquals(new String("haha")?? "haha");
Assert.assertNotNull(max);
Assert.assertTrue(true);
}
}