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了。
分享到:
相关推荐
org.junit.runner.RunWith.class org.junit.runner.Runner.class org.junit.runner.manipulation.Filter.class org.junit.runner.manipulation.Filterable.class org.junit.runner.manipulation....
单元测试—— Spring 环境下测试,所需要的jar包: spring-test-4.3.29.RELEASE.jar、junit-4.13.1.jar、hamcrest-core-1.3.jar。
@RunWith(SpringJUnit4ClassRunner.class)//Spring的Junit测试,会在测试开始时,创建Spring的应用上下文 @ContextConfiguration(classes=CDPlayerSpringConfig.class)//表明配置类 public class SpringTest1 { //...
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt....
@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class, ...
org.springframework.web.context.request.Log4jNestedDiagnosticContextInterceptor.class org.springframework.web.context.request.RequestAttributes.class org.springframework.web.context.request....
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt....
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt....
spring-test.jar 用在junit4以上 在类上写 @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"WIN-INF/config/applicationContext.xml" })
1)junit4的注解:@RunWith(value=SpringJUnit4ClassRunner.class) 2)spring-test的注解:@ContextConfiguration(locations={"classpath:applicationContext-test.xml"}) 5.方便svn管理,不会导致无效版本代码泛滥...
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/...
Classes contained in spring-mock.jar: org.springframework.mock.jndi.ExpectedLookupTemplate.class org.springframework.mock.jndi.SimpleNamingContext.class org.springframework.mock.jndi....
Unity可用的System.Drawing.dll (解决unity3d build时候的报错: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded)
编写basedao的时候报错:java.lang.Class cannot be cast to java.lang.reflect.Parameterized
主要介绍了tomcat报错:Wrapper cannot find servlet class ...问题解决的相关资料,需要的朋友可以参考下
Fatal error: Class ‘COM’ not found in XXXXXXXXX 没发现 COM 类,php代码主要是调用一些系统的信息,初想应该是php没配置好,在stackoverflow找到答案,是讨论xampp的,要延伸开来,我加了几个要点: ★ php 根...
Mybatis报错: org.apache.ibatis.exceptions.PersistenceException解决办法 ... Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating class com.fendo.entity.Person with invalid ty
启动报错:javax.servlet.ServletException:javax.xml.stream.FactoryConfigurationError: Provider for class javax.xml.stream.XMLInputFactory cannot be created。引入jar包解决问题
java.lang.IllegalStateException: The content of the adapter has changed but ... [in ListView(2131230720, class android.widget.ListView) with Adapter(class com.example.listviewdemo.UserListAdapter)]
20.2.4. Disabling Restart 20.2.5. Using a Trigger File 20.2.6. Customizing the Restart Classloader 20.2.7. Known Limitations 20.3. LiveReload 20.4. Global Settings 20.5. Remote Applications 20.5.1. ...