-1
我正在嘗試爲spring
項目編寫一些單元測試。下面是我想測試類和測試:春季使用Junit測試metods
@Component
public class EmployeeManager implements QuestionDAO {
private Manager manager;
@Autowired
public EmployeeManager(Manager manager) {
this.manager = manager;
}
public Category getSpecificCategory(Employee employee) {
return employee.getCategory();
}
}
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:META-INF/config.xml" })
public class EmployeeManagerTest extends MockObjectTestCase {
private EmployeeManager employeeManager;
@Autowired
private Manager manager;
@Override
public void setUp() {
this.manager = mock(Manager.class);
this.employeeManager = new EmployeeManager(manager);
}
@Test
public void testGetSpecificCategory() {
this.employeeManager.getSpecificCategory(new Employee("john","developer"));
}
}
運行測試時上面我得到
Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://xmlns.jcp.org/xml/ns/config]
Offending resource: class path resource [META-INF/config.xml]
在pom.xml
我添加了依賴關係junit
和spring-test
。
任何想法如何解決這個問題?