我创建了这个Dockerfile,并根据来自的示例将其复制到目录中。
FROM openjdk:8-jre-alpine
ENV WIREMOCK_VERSION 2.27.1
RUN apk add --update openssl
# fix "No Server ALPNProcessors" when using https
RUN apk add --update libc6-compat
RUN ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2
我希望为API创建一个Stub,并希望验证服务器返回的API调用和响应。为此,我实现了WireMock示例:
import org.junit.Rule;
import org.junit.Test;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
public class MockTestDemo {
private static final int WIREMOCK_PORT = 8080;
@Rule
public WireMockRule wireMockRule = new Wire
在我的机器人android测试中尝试启动一个WireMockServer时,得到了下面的堆栈跟踪。可能是Apache客户端的两个版本之间的冲突,但我还没有解决它。有什么想法吗?
java.lang.NoSuchMethodError: org.apache.http.conn.ssl.SSLSocketFactory.<init>
at com.github.tomakehurst.wiremock.http.HttpClientFactory.createSslSocketFactory(HttpClientFactory.java:110)
at com.github.toma
我最近用Slick等更新了我的Play Scala项目到2.3.8。
从那时起,我使用Wiremock的单元测试就一直失败。
错误看起来是:
The future returned an exception of type: java.lang.RuntimeException, with message: There is no started application.
如有任何帮助/建议,我将不胜感激?
class BlahTest extends FunSuite
with MockitoSugar with ScalaFutures
with SpanSugar with
我一直试图从Wiremock的文档中找到这个指南:
-高级使用.编程
因为我希望能够同时模拟多个主机(相同的主机,本地环境的唯一端口)。但是我不希望这些@RegisterExtension位于我的测试类中,而是放在单独的文件中,但是这样做,JUnit就不会捡到它们,我也不知道为什么。我是不是走错路了?
测试代码:
public class MyTest{
@Test
public void testMe(){
MyIntegration.mock();
}
}
public MyIntegration{
@RegisterExtension
sta
我试图在我的WireMock测试中使用JUnit来模拟对外部API的调用。
public class ExampleWiremockTest {
@Rule
public WireMockRule wireMockRule = new WireMockRule(9999);
@Before
public void setUp() {
stubFor(get(urlEqualTo("/bin/sillyServlet"))
.willReturn(aResponse()
.
假设应用程序依赖于外部服务器,上的REST服务。为了进行测试,我想在JUnit环境中模拟外部rest调用(通过Wiremock)。启动单独的服务器会消耗时间,而且并不容易。使用WiremockRule似乎是正确的方向。创建模拟控制器并不是一种优雅的方法,因为Wiremock是可用的。
例如get( "");
PS:当然,我知道我可以通过Mockito模拟REST调用。
用Wiremock模拟本地主机是一种简单的方法。如何使用该代码来模拟、其他服务器、和服务?我从流行的Baeldung示例中复制了部分内容。
public class WireMockDemo {
@Rul
我正在尝试测试具有底层GET调用HTTP服务器的代码。
我正在尝试使用,并且基于“入门”,我有以下代码:
@Rule
public WireMockRule wireMockRule =
new WireMockRule(WireMockConfiguration.wireMockConfig().port(8888)); // No-args constructor defaults to port 8080
@BeforeClass
public static void beforeClass(){
stubFor(get(urlEqualTo("/Path/G
我正在为一个资源编写一个集成测试(Jax-rs with resteasy),它调用一个第三方请求到Trustpilot Api,以获得一个产品的评审链接。在我的测试中,我想通过使用Wiremock来模拟这个调用,并使用调用请求。下面的代码显示了我的设置(名称等被更改)。
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { MyResourceTestContext.class })
public class MyResourceIntegrationTest {
@Rule
p
这是我的考试课:
public class CompanionDevicesRestServiceTest {
public static ComDevicesRestService comDevicesRestService;
public static IComDevices cdevicesService;
public static ComDevices cdevicesRequest;
@BeforeClass
public static void init(){
cdevicesService = new StubComD
我正在使用Robolectric、gradle口味和wireMock进行一个项目,使用以下文件夹结构来模拟我的the服务:
app
main (common classes)
flavor1
Constant (class with url for this flavor)
flavor2
Constant (class with url for this flavor)
testDebug
Constant (class with url pointing to wireMock standalone)
Common test for flavor1 and f
我有以下情况:
@Transactional
@SpringBootTest
@ActiveProfiles("test")
@AutoConfigureMockMvc
@AutoConfigureWireMock(port = 0)
public abstract class IntegrationTest {
}
public class Test1 extends IntegrationTest {
// Tests that use WireMock
}
@ActiveProfiles("specific-case-test") // This