2016-01-26 183 views
-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我添加了依賴關係junitspring-test

任何想法如何解決這個問題?

回答

相關問題