I had a dynamic web project which I configured to use Maven. Now I am trying to run unit testing the login servlet(with JUnit, without spring), but eclipse always gives me the same error when I try to run the test case. The error is: 'An internal error occurred during: "Launching LoginPatientTest". Cannot invoke "org.eclipse.m2e.core.project.IMavenProjectFacade.getMavenProject (org.eclipse.core.runtime.IProgressMonitor)" because "facade" is null'. My test case is :
package control;
import static org.mockito.Mockito.*;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import model.ProfileManager;
import model.Bean.PatientBean;
public class LoginPatientTest {
String fiscal_code;
String user_password;
@Before
public void setUp() throws Exception {
fiscal_code = "aaaaaaa";
user_password = "bbbbb";
}
@After
public void tearDown() throws Exception {
}
@Test
public void testPresent() throws IOException, ServletException{
HttpServletRequest req = mock(HttpServletRequest.class);
HttpServletResponse res = mock(HttpServletResponse.class);
HttpSession session = mock(HttpSession.class);
when(req.getSession()).thenReturn(session);
ProfileManager pm = mock(ProfileManager.class);
when(pm.ReturnPatientByKey(fiscal_code, user_password)).thenReturn(new PatientBean());
LoginPatient servlet = new LoginPatient();
servlet.doPost(req, res);
}
}