spring-test相关内容
我有一个 spring boot 应用程序,主类如下: @SpringBootApplication公共类应用{public static void main(String[] args) 抛出异常 {SpringApplication.run(Application.class, args);}} 现在我想测试我的服务并创建了一个基础测试类: @SpringApplicationConfi
..
我正在使用 Spring Boot 1.4.0.RELEASE.我正在为我的控制器类编写测试.我收到以下异常. org.springframework.beans.factory.UnsatisfiedDependencyException:创建名为“com.concur.cognos.authentication.service.ServiceControllerITTest"的bean时出错
..
我在模型中使用 LocalDateTime,在包含 LocalDateTimeDeserializer 之后,将 bean 字段转换为 @NotNull@Column(name = "创建")@JsonDeserialize(使用 = LocalDateTimeDeserializer.class)私人 LocalDateTime 创建; 并包括 spring.jackson.seriali
..
我无法构建我的全新项目.我使用 https://start.spring.io/ 来生成一个全新的 Spring 2.0 MongoDB Maven 项目,并且我想要一个嵌入式 MongoDB 数据库用于我的集成测试.spring 初始值设定项为此添加了 de.flapdoodle.embed.mongo 的依赖项. 但是每次我尝试运行“mvn clean package"时,我在测试过程中
..
我有一个带有REST控制器的Springboot应用程序,并为此编写了Mockito单元测试用例.问题是我在运行测试用例时通过在RestController中读取messageSource来获取NoSuchMessageException.但是在实际使用Postman或其他Rest客户端调用它时不会发生.(我使用龙目岛来避免样板代码.) 其余控制器代码 @RestController@R
..
我有一个JMS Spring Boot项目,我正在尝试与我的JMS侦听器进行集成测试,并且我使用了Mockito模拟来模拟带有外部服务调用的bean. 在测试期间,我遇到了一个问题,其中 Mockito.when / thenReturn 在我的JMS侦听器中返回了 null . 我正在使用 @MockBean 作为有问题的服务,但是当我使用 @Bean 并返回 Mockito.moc
..
在每次测试执行后,如何使用Junit5和Spring Boot清除应用程序上下文?我希望在测试中创建的所有bean在执行后都被销毁,因为我要在多个测试中创建相同的bean.我不想为所有测试都使用一个配置类,但是每个测试都需要一个配置类,如下所示. @ExtendWith(SpringExtension.class)@ContextConfiguration(类= MyTest.ContextC
..
我在用@Configuration装饰的类中定义了 Bean : @Configuration公共类MyBeanConfig {@豆角,扁豆公共字符串configPath(){返回"../生产/环境/路径";}} 我有一个用@TestConfiguration装饰的类,该类应覆盖此 Bean : @TestConfiguration公共类MyTestConfiguration {@豆角
..
我正在测试下面给出的控制器 @Controller公共类MasterController {@GetMapping("/")公共字符串goLoginPage(){返回“索引";}} 我正在使用此 Spring文档来测试我的控制器.现在,我想通过仅实例化Web层而不是文档中给出的整个Spring上下文来测试我的控制器.下面是我的相同代码. @RunWith(SpringRunner.cl
..
升级到新发布的Spring Boot的 2.2.0.RELEASE 版本后,我的某些测试失败了.看来 MediaType.APPLICATION_JSON_UTF8 已被弃用,并且不再从未明确指定内容类型的控制器方法中作为默认内容类型返回. 类似的测试代码 字符串内容= mockMvc.perform(get("/some-api").contentType(MediaType.APPLI
..
嗨,我有一个Spring Boot应用程序(2.3.1.RELEASE,ojdbc8),基本上它已连接到oracle数据库. spring boot应用程序在连接到oracle db时开始查找,但是在以下情况下无法启动集成测试已连接到H2嵌入式数据库,并且我的某些查询失败并显示以下错误消息: 原因:java.lang.NullPointerException:空在org.hibernate
..
根据文档( https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/test/context/junit/jupiter/EnabledIf.html#表达式-),您可以使用@EnabledIf批注 在这样的测试类或测试方法上: @EnabledIf("${smoke.tests
..
准确地说,要看我有什么错误. 如果我使用Intellij Maven Install,则会收到此异常(这很奇怪,因为我具有此依赖关系,并且如果我没有记错的话,默认情况下应在spring-starter-test中将其设置为默认值): Caused by: java.lang.ClassNotFoundException: ch.qos.logback.classic.turbo.Tur
..
我正在编写集成测试以测试我的端点,并且需要在构造后立即在数据库中设置用户,以便Spring Security Test批注@WithUserDetails可以从数据库中收集用户. 我的班级设置是这样的: @RunWith(value = SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvi
..
我正在尝试测试家用控制器 @RequestMapping("/") @ResponseBody String home() { return "Hello World!"; } 我使用的是春季安全性,使用用户名"user",默认情况下使用密码进行测试,但是@PreAuthorize无法正常工作 @RunWith(SpringRunner.class) @SpringBoot
..
我的Service类在下面,然后是它的测试- @Service public class MyServiceImpl implements MyService { @Autowired private RestTemplate restTemplate; @Override public StudentInfo getStu
..
我将junit5与spring-starter-test一起使用,为了运行弹簧测试,我需要使用@ExtendWith而不是@RunWith.但是@IfProfileValue可与@RunWith(SpringRunner.class)一起使用,但不能与@ExtendWith(SpringExtension.class)一起使用,以下是我的代码: @SpringBootTest @Extend
..
我正在尝试提高我正在研究的项目的Spring集成测试的性能.我们正在使用Spring + Gradle + JUnit. 在build.gradle文件中具有以下配置: test { useJUnit() setForkEvery(0) setMaxParallelForks(1) } 我们能够在单个JVM中运行所有测试.尽管我认为这是默认行为. 但是
..
如何告诉@Sql注释对于该类仅运行一次,而不对于每个@Test方法仅运行一次? 是否具有与@BeforeClass相同的行为? @org.springframework.test.context.jdbc.Sql( scripts = "classpath:schema-test.sql", executionPhase = Sql.ExecutionPhase.B
..
我能够获得Spring Boot集成,以生成一个随机的自由端口来启动自身.但是我还需要一个Redis的免费端口. @ContextConfiguration(classes = {MyApplication.class}, loader = SpringApplicationContextLoader.class) @WebIntegrationTest(randomPort = true,
..