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

Global RestAssured.baseURI Overwritten by Multiple Base Classes in Serenity BDD #3620

Open
yavgel opened this issue Feb 21, 2025 · 0 comments

Comments

@yavgel
Copy link

yavgel commented Feb 21, 2025

What happened?

Description:
When using Serenity BDD with RestAssured, multiple base classes (e.g., ApiBaseOne and ApiBaseTwo) each set RestAssured.baseURI in their static blocks or constructors. Whichever class loads last overwrites the global baseURI. As a result, tests that expect different base URIs end up failing with 404/405 errors because they are hitting the wrong environment.

Steps to Reproduce:

  1. Create two base classes that each set RestAssured.baseURI in a static initializer.
  2. Run tests that call endpoints from both classes.
  3. Observe that the second base class to load overwrites the baseURI for all subsequent tests.

Expected Behavior:

  • Each test should be able to use its own environment-specific base URI without being overwritten by another test.

Actual Behavior:

  • Tests for one API end up hitting the base URI of the other API, leading to HTTP 404 or 405 errors.

Workarounds Tried:

  • Using <parallel>none</parallel> in the Maven Surefire/Failsafe plugins did not fully resolve the issue.
  • Attempting to reinitialize RestAssured.baseURI in each test step still leads to overwrites if multiple base classes do the same.
  • Switching to a per-request RequestSpecification for each API solves the conflict, but a global approach with multiple different base URIs does not appear to be supported.

Environment:

  • Serenity BDD version: 4.2.16
  • RestAssured version: 5.3.0
  • Java 17
  • Maven 3.8.x

Additional Context:

  • The problem occurs whenever two different sets of tests require different base URIs in the same test run.
  • A single global RestAssured.baseURI works if the entire suite uses one environment, but not when multiple base classes each set their own URI.

Suggested Enhancement:

  • Provide a mechanism in Serenity BDD to handle multiple RestAssured base URIs without global overwrites (e.g., a recommended approach for multiple base classes).
  • Improve documentation or warnings when multiple classes set RestAssured.baseURI, to guide users toward a per-request or per-base-class specification solution.

What did you expect to happen?

this approach: https://johnfergusonsmart.com/environment-specific-configuration-in-serenity-bdd/

Serenity BDD version

4.2.16

JDK version

17

Execution environment

No response

How to reproduce the bug.

please see above

How can we make it happen?

Work on this myself and propose a PR (with Serenity BDD team guidance)

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

1 participant