Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure moco calls when one or more API is hit? #348

Open
ahsanbagwan opened this issue Dec 11, 2024 · 1 comment
Open

How to configure moco calls when one or more API is hit? #348

ahsanbagwan opened this issue Dec 11, 2024 · 1 comment

Comments

@ahsanbagwan
Copy link

ahsanbagwan commented Dec 11, 2024

We have some APIs where we only need to hit one external api and the format is as below. However there are also cases when we need to hit a couple more external services.
How to maintain sequence in those cases? One call after another repeating the mock as well as actual hitting the controller API?

@Test
public void testSomething() throws Exception {
    mocoServer.request(endsWith(uri("/sample-endpoint")))
        .response(with(sampleResponse), status(STATUS_CODE_200), header(contentType ,contentTypeJsonUtf));


    running(mocoServer, () -> {
        //Test case fails without the below delay
        TimeUnit.SECONDS.sleep(2);

        Response svResponse = restAssuredAssistantAPIPOST(STATUS_CODE_400, dataUrl,
            dataHappyRequestBody);

        assertEquals(STATUS_CODE_400, svResponse.getStatusCode());

    });
}
Repository owner deleted a comment from ComeonBug Dec 13, 2024
@dreamhead
Copy link
Owner

@ahsanbagwan You can run your other test code before your restAssuredAssistantAPIPOST in running, because Moco server has started inside running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants