spring-test相关内容
我在一个特性文件中有 4 个测试,有 2 个不同的标签 @first 和 @then.我希望@first 测试首先以并行方式运行,@then 测试在所有@first 测试完成后运行,同时也具有并行性. 项目在这里:https://github.com/marcesso/qafTesting @CucumberOptions(plugin = {“com.qmetry.qaf.automat
..
控制器 @RestController@验证类我的控制器{@GetMapping("/foo")public String unwrapped(@Min(1) @RequestParam("param") int param) {返回 Integer.toString(param);}@GetMapping("/bar")公共字符串包装(@ModelAttribute @Valid Wrappe
..
我正在使用带有 TestNG 的 Spring Test 来测试我们的 DAO,并且我想在某些方法之前运行特定的文本夹具脚本,允许在每个方法之后回滚修改,以便测试可以自由地执行任何操作夹具数据. 最初我认为 'groups' 适合它,但我已经意识到它们不适合这个(见这个问题:TestNG BeforeMethod with groups ). 有没有办法将 @BeforeMethod
..
我们的应用程序是通过使用 Hystrix 实现断路器模式以抗脆弱的方式编写的. 整个应用程序是使用测试驱动的实践创建的,但卡在了我们需要通过在方法上配置相同来实现断路器策略的点. 以下是我们使用的示例配置 - @HystrixCommand(commandProperties = {@HystrixProperty(name = "circuitBreaker.enabled", v
..
我正在使用 spring 批次 4.0,我正在尝试测试我的批次.我会将嵌入式数据库 h2 与 @JpaDataTest 一起使用,但它不起作用.当我添加此注释时出现错误 java.lang.IllegalStateException:在 JobRepository 中检测到现有事务.请修复此问题并重试(例如,从客户端删除 @Transactional 注释). @Test 上的@Tra
..
我有一个测试,用于测试 Spring 应用程序的各个部分.它使用 SpringRunner 和 annotaion @SpringBootTest 所以它正在启动一个完整的 spring 服务器. 问题是测试正在由无权访问数据库的服务器执行,因此我收到很多连接超时,这会减慢测试速度. 连接问题本身并不是真正的问题,因为测试是在模拟对数据库的调用,因此它们不依赖于存在的连接.只是测试很慢
..
我想用 DataJpaTest 注释测试我的服务层.我的设置如下:SpringBoot 2.0.0-M7、JAVA 9 和 pom xml : org.springframework.bootspring-boot-starter-webflux
..
我使用嵌入式 Mongo DB 数据库按以下方式配置了 Spring 集成测试: @WebAppConfiguration@ContextConfiguration(classes = TpimApplication.class)//@SpringBootTest(classes=SPApplication.class)//@WebMvcTest(controllers = {Controlle
..
我的 Spring Boot 2 测试文件夹中有以下层次结构 测试/爪哇/包名/SpringBootTest.java资源/测试属性 SpringBootTest 有一个类似的代码 @RunWith (SpringRunner.class)@TestPropertySource(locations = {"/resources/test.properties"})@SpringBootTe
..
我想测试这样的方法 @PostMapping(value = "/test")公共字符串测试(@Valid TestModel 模型){返回模型.getUsername();} TestModel 就是这个 @Getter@Setter公共类测试模型{私有 MultipartFile[] image1;私有 MultipartFile[] image2;私有 MultipartFile[]
..
我有一个用 @Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts="someScript") 注释的抽象类. 我有一个从抽象类继承的测试类.子类也用 @Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts="someOtherScript")
..
让我们以以下为例. @Autowired@MockBean私人 Foo foobar; Spring Context 是否先加载类 Foo,然后再应用模拟?或者 @Mockbean 是否以某种方式被检测到,Spring 创建并应用模拟而不是将 Foo 类加载到 Spring 上下文中.我怀疑是后者,但我想确认一下. 解决方案 Spring 会抛出异常. 让我们定义 Foo 类.
..
当我使用以下注释启动我的测试时: package com.hello.package.p1;@RunWith(SpringRunner.class)@DataMongoTest@SpringBootTest公共类 ClassATest {@自动连线服务 1 服务 1;//fqn = com.hello.package.p1.Service1@自动连线服务 2 服务 2;//fqn = com.h
..
我有一个简单的生产者类,定义如下: @Configuration公共类 MyKafkaProducer {私有最终静态记录器日志 = LoggerFactory.getLogger(MyKafkaProducer.class);@Value("${my.kafka.producer.topic}")私人字符串主题;@自动连线KafkaTemplate卡夫卡模板;public void sendD
..
最近,Spring Boot 增加了 TypeExcludeFilters.一个突出的用例是 SpringBootApplication 注释. 在 Spring Boot 1.4 之前: //...@ComponentScan公共@interface SpringBootApplication {//... 从 Spring Boot 1.4 开始: //...@ComponentS
..
我正在尝试使用 Spock 为我的 Spring Boot 1.4.0 编写一些测试,但我的 application-test-properties 文件没有被选中. 我的gradle里有这个: 依赖项{编译('org.springframework.boot:spring-boot-starter-data-jpa')编译('org.springframework.boot:spring
..
我无法在 spring boot 1.4 中运行简单的测试.我按照官方网站的教程 testing-the-spring-mvc-slice 但我没有让它工作. 每次我收到以下错误: java.lang.IllegalStateException:无法找到@SpringBootConfiguration,您需要在测试中使用@ContextConfiguration 或@SpringBootT
..
我有写入数据库的 Spring Batch 作业(它有一个带有 JpaItemWriter 的步骤).我有一个集成测试,如下所示: @RunWith(SpringRunner.class)@SpringBootTest@ActiveProfiles("integrationTest")公共类 LoadApplicationTests {@自动连线私人工作;@自动连线私有 JobRepositor
..
在 OAuth 资源服务器配置的 Web 应用程序中再次运行 Spring Boot 集成测试的最佳方法是什么. 我可以想到两种理论方法: 在不实际调用授权服务器的情况下模拟资源服务器中的安全上下文. 嵌入授权服务器作为测试的一部分并将身份验证重定向到它. 我想知道其他人是如何解决这个问题的. 解决方案 我使用 spring security 4.x @WithSecu
..
我的课程是.. 位于 src/intregation-test/java @RunWith(SpringRunner.class)@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = StoreOrderFulfillmentApplication.class)@ActiveProfiles("测试")
..