public class TestHello {
private HelloWorld hw;
@Before
public void setUp() {
hw = new HelloWorld();
}
@Test
public void testHello() {
String str = hw.hello();
assertEquals("hello 测试失败",str,"world");
}
@Test
public void testWorld() {
String str = hw.world();
assertEquals("world 测试失败",str, "hello");
}
@Test
public void testNil() {
assertNull("对象不为空",hw.nil());
}
@Test
public void testNotNil() {
assertNotNull("对象为空", hw.notNil());
}
@Test(expected=NumberFormatException.class)
public void testExt() {
hw.ext();
}
@After
public void tearDown() {
hw = null;
}
}