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

Use mocks for remote/integration testing #331

Open
ascheman opened this issue Aug 13, 2024 · 5 comments
Open

Use mocks for remote/integration testing #331

ascheman opened this issue Aug 13, 2024 · 5 comments
Assignees
Labels
enhancement hacktoberfest This is a nice ticket for the hacktoberfest help-needed

Comments

@ascheman
Copy link
Member

As developer of HSC I would like to use a mock service to test for misc. external resources as the real resources are sometimes not stable which leads to frequent flaky errors and unstable builds.

@ascheman ascheman added the hacktoberfest This is a nice ticket for the hacktoberfest label Sep 7, 2024
@RehanChalana
Copy link

Hey @ascheman

I have some experience with testing. I would love to contribute!

Can you help me on where to start from

@ascheman
Copy link
Member Author

ascheman commented Oct 1, 2024

Hi @RehanChalana,

thanks a lot, I appreciate your offer.

My idea would be to mock away external services which are used for testing (and are somewhat unstable in their availability).
If you take htmlSanityCheck-core/src/test/groovy/org/aim42/htmlsanitycheck/check/BrokenHttpLinksCheckerSpec.groovy as a starting point, you will find several good and bad URLs referring to external sites. If you run the test case while not connected to the Internet, it will run into (false) errors.

Hence, I would like to start a (local) mock service and run the tests against the mocked endpoints. Suitable technologies could be Wiremock, and perhaps Testcontainers? But I am happy if you see another approach.

@RehanChalana
Copy link

Thank you so much for the detailed response!

To start, I am working on htmlSanityCheckcore/src/test/groovy/org/aim42/htmlsanitycheck/check/BrokenHttpLinksCheckerSpec.groovy I’m trying to use WireMock as you mentioned, but I’ve encountered an issue since its latest version requires Java 11 or higher. I’m still figuring it out but its fun!

@ascheman
Copy link
Member Author

ascheman commented Oct 1, 2024

Are you on (the Hacktoberfest) Discord? You can reach out to me (gerdaschemann) so we could have a chat about the problems you encounter (or if you need any other support).

I am also happy if you will contribute to the development documentation of the project if you manage to solve your issues. A second PR wrt. to docs could increase your Hacktoberfest score.

@RehanChalana
Copy link

Yes i am on discord! as well as participating in hacktoberfest!

I sent you a friend request on discord as well. my username is rc__22.

Thanks !

RehanChalana added a commit to RehanChalana/htmlSanityCheck that referenced this issue Oct 12, 2024
…mHostNameResolver

- fixes aim42#331
- Updated all URLs in test cases to use WireMock with Testcontainers.
- Integrated CustomHostNameResolver to ensure tests run without internet.
- Updated `mappings.json` with mappings for all test URLs.
- Remove test for recognizing internet connectivity.
RehanChalana added a commit to RehanChalana/htmlSanityCheck that referenced this issue Oct 12, 2024
- Added WireMockContainer to BrokenHttpLinksCheckerSpec for mocking HTTP responses.
- progress towards fixing aim42#331
- Configured WireMock to use mappings.json for predefined request-response mappings.
RehanChalana added a commit to RehanChalana/htmlSanityCheck that referenced this issue Oct 12, 2024
RehanChalana added a commit to RehanChalana/htmlSanityCheck that referenced this issue Oct 12, 2024
RehanChalana added a commit to RehanChalana/htmlSanityCheck that referenced this issue Oct 12, 2024
…mHostNameResolver

- fixes aim42#331
- Updated all URLs in test cases to use WireMock with Testcontainers.
- Integrated CustomHostNameResolver to ensure tests run without internet.
- Updated `mappings.json` with mappings for all test URLs.
- Remove test for recognizing internet connectivity.
RehanChalana added a commit to RehanChalana/htmlSanityCheck that referenced this issue Oct 13, 2024
- Added WireMockContainer to BrokenHttpLinksCheckerSpec for mocking HTTP responses.
- progress towards fixing aim42#331
- Configured WireMock to use mappings.json for predefined request-response mappings.
RehanChalana added a commit to RehanChalana/htmlSanityCheck that referenced this issue Oct 13, 2024
RehanChalana added a commit to RehanChalana/htmlSanityCheck that referenced this issue Oct 13, 2024
RehanChalana added a commit to RehanChalana/htmlSanityCheck that referenced this issue Oct 13, 2024
…mHostNameResolver

- fixes aim42#331
- Updated all URLs in test cases to use WireMock with Testcontainers.
- Integrated CustomHostNameResolver to ensure tests run without internet.
- Updated `mappings.json` with mappings for all test URLs.
- Remove test for recognizing internet connectivity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement hacktoberfest This is a nice ticket for the hacktoberfest help-needed
Projects
None yet
Development

No branches or pull requests

2 participants