问题标签 [springjunit4classrunner]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
spring - 使用 Spring 配置文件将特定 bean 注入 DAO
在我的 web 应用程序中,applicationContext 中有两个数据源 bean,一个用于真实环境,一个用于执行测试。dataSource 对象被注入到一个 DAO 类中。使用 Spring 配置文件我如何配置测试 dataSource 应该在运行测试(JUnit)时注入 DAO 和 real-env dataSource 应该在代码部署到 real-env 时注入 DAO?
spring - @RunWith(SpringJUnit4ClassRunner.class) 无法使用 NULL 'contextLoader' 加载 ApplicationContext
我有这个代码,
并运行测试,有错误
原因:java.lang.IllegalArgumentException:无法使用 NULL 'contextLoader' 加载 ApplicationContext。考虑使用 @ContextConfiguration 注释您的测试类。在 org.springframework.util.Assert.notNull(Assert.java:112) 在 org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:276) 在 org.springframework.test.context.TestContext.getApplicationContext(TestContext .java:304) ... 还有 28 个
然后,我找到与 SO 相同的 Q,解决方案是
事实上,对于这个 pojo,我不需要 xml 配置。我会得到其他错误
原因:java.io.FileNotFoundException:类路径资源 [/JunitDemo-context.xml] 无法打开,因为它在 org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158) 中不存在。 springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328) ... 37 更多
如何正确运行我的程序?</p>
spring-ws - 用于 Spring WebServiceTemplate 的 JUnit 不起作用
我正在使用 Spring WebServiceTemplate 使用 SOAP Webservice。在执行 JUnit 时,我遇到了一个问题。
我的客户类:
我的测试课:
问题:
当我执行我的测试用例时,我的客户端类中的“webServiceTemplate.marshalSendAndReceive(request)”行出现 NullPointerException。
webServiceTemplate 即将为空。
知道我做错了什么吗?
spring - 无法在 Spring Junits 中为事务打开 JDBC 连接
Spring junit 在 Maven 构建期间失败。如果我单独运行每个测试用例,它工作正常。如果我批量运行,那么只有我收到以下错误。Spring 版本是 4.3.0,Junit 版本是 4.12
例外:
原因:java.sql.SQLException:侦听器拒绝连接并出现以下错误:ORA-12520,TNS:侦听器找不到请求的服务器类型的可用处理程序
java - 带有@RunWith(SpringJUnit4ClassRunner.class) 的配置文件
我的 TestSuite 有两种配置,它们为注入提供了不同的 bean。只要我使用注释设置我的个人资料,这就会起作用。
@ActiveProfiles( profiles={"a"})
和@ActiveProfiles( profiles={"b"})
但我似乎无法从属性源文件中设置它
我的注释看起来像
的内容application.properties
是
结果导致不满意的依赖
正如上面提到的设置@ActiveProfiles
一样,并且使用了正确的被使用。
几乎就好像 PropertySource 和/或 TestPropertySource 不适用@RunWith(SpringJUnit4ClassRunner.class)
spring - Spring Boot Main 类 Junit 测试抛出错误
这是 Spring Boot 主类
这是这个类的junit类
得到这个异常
更新应用程序的配置
有人可以帮我解决这个问题吗?
spring-boot - springboottest如何防止运行应用程序
我有运行 Spring 批处理 ETL 的标准 Application 类:
我的 Junit 测试执行如下操作:
我的问题是,当我执行 junit 测试时,应用程序也会启动 ETL,然后执行测试。如何阻止应用程序运行?
java - 仅使用 @Component 和 @Autowired 使用 SpringJUnit4ClassRunner 进行单元测试
我有以下课程:
我如何在不模拟注入的 bean 的情况下对其进行测试?我没有配置 [XML 或声明性]。我做了以下事情:
spring-boot - spring-integration-file 的 junit 测试用例
我是春天的新手。我有一个使用 spring-integration-file (spring boot- FTP,SFTP,NFS) 创建的 spring 项目,它将文件从源路径转换为目标路径。
必须编写junit测试用例来测试项目。如果有人共享一些文档/链接以使用 @RunWith(SpringRunner.class) 为 spring-integration-file 项目编写 junit 测试用例,这将很有帮助
提前致谢
spring-boot - @SpringBootTest - 无法加载应用程序上下文
测试类:
}
应用 :
应用配置:
有 Bootstraploader 类。
错误:
资源位置: