'Writing unit tests for tapir endpoints (API Layer) in scala

I have created tapir endpoints in scala, where the architecture of the project is such that API layer calls service layer and service layer calls repo layer.

I have written unit tests for service and repo layer (using mockito), but now I could not find a good library which can be used in scala to test api layer by mocking methods of service layer. Basically by writing unit tests for endpoints I want to test validations in api layer.

P.S. I tried using RestAssured library but it seems to be helpful for writing integration test, but not for unit test.

Edited:

The underlying server framework used is Akka HTTP



Solution 1:[1]

Tapir itself does not expose endpoints, it's your http server framework that does it (http4s, zio, play...).

That means that for testing your endpoints, you should rely on what your http server framework offers: Tapir is an implementation detail, forget about it for these tests.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gaël J