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

Using the same Class for RestAssured and RestAssuredMockMvc #1141

Open
acet opened this issue Feb 26, 2019 · 1 comment
Open

Using the same Class for RestAssured and RestAssuredMockMvc #1141

acet opened this issue Feb 26, 2019 · 1 comment

Comments

@acet
Copy link

acet commented Feb 26, 2019

Hello,
Please consider the code at
https://github.com/acet/rest_assured_demo_spring_starter
As you can see there are 3 levels of testing:
test - Spring webmvc unit test
integTest - Spring boot integration test
functionalTest - cucumber functional test

com.acet.testphases.demo.RestClient
This uses a MockMvc backed RestAssured to call the single endpoint available (test and integTest)

com.acet.testphases.demo.FunctionalTestRestClient
This uses standard RestAssurred to call the endpoint when the application is deployed (functionalTest)

As you can see the method "getSum" in both is the same. From what I have found though I need to have the two implementations of RestClient as I must import either
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
or
import static io.restassured.RestAssured.given;

Do you know is there some way I could create a common RestClient here that may or may not be backed by MockMvc?

Thanks in advance.

@acet acet changed the title Using the same class for RestAssurred and MockMvcRestAssurred Using the same class for RestAssurred and RestAssuredMockMvc Feb 26, 2019
@acet acet changed the title Using the same class for RestAssurred and RestAssuredMockMvc Using the same Class for RestAssured and RestAssuredMockMvc Feb 27, 2019
@johanhaleby
Copy link
Collaborator

They are so different implementations so I've not even considered a single endpoint. It's not possible, in a generic way, to know if the server is implemented using Spring MVC and if you want to use MockMvc to test it. So I don't think it makes sense with a single API entry.

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