首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件开发 >

错误测试DEMO

2012-07-02 
异常测试DEMOpackage com.lijunimport static org.junit.Assert.*import org.junit.Beforeimport org.j

异常测试DEMO

package com.lijun;import static org.junit.Assert.*;import org.junit.Before;import org.junit.Test;public class Junit4ExceptionTest {private User user;@Beforepublic void init() {user = null;}@Test(expected = NullPointerException.class)public void testUser() {//assertNotNull(user.getUserName());user.getUserName();}}class User {private String userName;public String getUserName() {return userName;}public void setUserName(String userName) {this.userName = userName;}}

热点排行