io.mock-box:mock-box

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


Keywords
java, junit, kotest, kotlin, mock, mock-framework, mock-server, mocking, mocking-framework, mocking-library, mocks, spring-boot, stubs, tcp-mock-server, tcp-server, test-driven-development, testing, testing-framework, testing-library, testing-tools
License
Apache-2.0

Documentation

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();
}