kimkuma / mock-box

Mock-Box is a lightweight and powerful mock library that supports testing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mock-Box

Mock-Box is a lightweight and powerful mock library that supports testing.

Maven Central CI codecov License Twitter

How to use

MockTcpServer

@BeforeEach
void setUp() {
    mockTcpServer = MockTcpServerBuilder.builder()
        .handler(new EchoTcpHandler()) Or .handler(new MessageTcpHandler("Bye"))
        .port(PORT_NO)
        .buildAndStart();
}

@Test
void test() {...}

@AfterEach
void tearDown() {
    mockTcpServer.stop();
}

MockHttpServer

@BeforeEach
void setUp() {
    mockHttpServer = MockHttpServerBuilder.builder()
        .addHandler(new HttpJsonHandler(HttpMethod.GET, "/hello", responseObject))
        .port(PORT_NO)
        .buildAndStart();
}

@Test
void test() {...}

@AfterEach
void tearDown() {
    mockHttpServer.stop();
}

About

Mock-Box is a lightweight and powerful mock library that supports testing.

License:Apache License 2.0


Languages

Language:Java 100.0%