针对某个接口实现单元测试
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.hx.ssh.bean.Login;
public class LoginServiceTest {
//不继承extends TestCase
private static LoginService loginService;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");
loginService = (LoginService)ctx.getBean("loginService");
}
@Test
//添加测试注释,方法名以test开头
public void testSave(){
Login login = new Login("sff");
loginService.save(login);
}
}