简体   繁体   English

关于使用模拟条带进行 e2e 测试

[英]Regarding using mock stripe for e2e tests

I came across stripe mock( https://github.com/stripe/stripe-mock ) recently, for local testing,我最近遇到了条纹模拟( https://github.com/stripe/stripe-mock ),用于本地测试,

public PaymentMethod createPaymentMethod(Card card) {
      var paymentMethodParams =
          PaymentMethodCreateParams.builder()
              .setType(Type.CARD)
              .setCard(
                  CardDetails.builder()
                      .setNumber(card.getNumber())
                      .setExpMonth((long) card.getExpiryMonth())
                      .setExpYear((long) card.getExpiryYear())
                      .setCvc(card.getCvv())
                      .build())
              .build();
      var response = testMode? "Make API call to mock stripe with params" : PaymentMethod.create(paymentMethodParams);
      return response;
  }

Now I do not want to manually make http call to stripe mock server with http client and request body, Is there a way to change something in RequestOptions or use a different dependency to make the call?现在我不想使用 http 客户端和请求正文手动使 http 调用条带模拟服务器,有没有办法更改RequestOptions中的某些内容或使用不同的依赖项进行调用?

Basically, I dont want to do, something like基本上,我不想做,比如

String url = String.format("%s%s", Stripe.getApiBase(), String.format("/v1/payment_methods/%s", ApiResource.urlEncodeId(paymentMethod)));

just somehow override the stripe base API URL.只是以某种方式覆盖条带基础 API URL。

Stripe.overrideApiBase(); is something useful, but its static to stripe java library, I want normal stripe calls to go through, when my e2e tests are running.是有用的,但它的 static 对 java 库进行条带化,我希望在我的 e2e 测试运行时通过对 go 的正常条带调用。

Stripe.overrideApiBase() is likely what you want; Stripe.overrideApiBase()可能是您想要的; you'd just want to configure your app to only override it when running end to end tests.您只想将您的应用程序配置为仅在运行端到端测试时覆盖它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jersey e2e使用Spring的JDBCTemplate对内存数据库进行集成测试 - Jersey e2e integration tests for in-memory database using Spring's JDBCTemplate 使用量角器e2e测试来测量代码覆盖率Java - Measuring code coverage java using protractor e2e test 如何在maven中为Java项目组织单元,集成,e2e测试文件夹结构? - How to organise unit, integration, e2e tests folder structure in maven for a Java project? 使用 REST 模板进行 Spock E2E 测试 - Spock E2E test with REST template 将Stripe与多个电子商务客户端一起使用 - Using Stripe with multiple e-commerce clients 关于Java <E> 在公共场合 <E> 虚空 - Java regarding <E> in public static <E> void Java - 令牌流OAuth 2 E2E带代码 - Java - Token flow OAuth 2 E2E with code 尝试在我的e2e文件夹上运行“ gulp”时,发生生成错误 - when attempting to run 'gulp' on my e2e folder a spawn error occurs java.lang.ArrayStoreException 在 E2E 测试中由带有自定义验证组的自定义约束注释引起 - java.lang.ArrayStoreException in E2E Test caused by custom Constraint Annotation with Custom Validation Group 实施堆栈 <E> 使用向量 <E> - Implementing a Stack<E> using Vector<E>
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM