I have a JUnit 4 test class in Eclipse Ganymede that has the following annotations :
I have a JUnit 4 test class in Eclipse Ganymede that has the following annotations :
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/applicationContext.xml"})
public class TestSybaseDao extends TestCase {
This annotation gives compilation error "Type mismatch: cannot convert from Class<SpringJUnit4ClassRunner> to Class<? extends Runner>
在寫單元測試的時候,明明包導進去了但是鼠標放到調用類還會出現這個錯誤。
出現這種情況一般有2個原因:
1.可能剛加進去的包為加載到,需要到重構配置窗口中重新加載下所有包,一般eclipse自帶的是junit4.4版本的。
2.第二種原因是spring不支持junit4.5一下的版本。所以只需要把junit4.4或者更低版本升級到更高就ok了。
