htmlSanityCheck icon indicating copy to clipboard operation
htmlSanityCheck copied to clipboard

Use mocks for remote/integration testing

Open ascheman opened this issue 1 year ago • 5 comments

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 avatar Aug 13 '24 07:08 ascheman

Hey @ascheman

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

Can you help me on where to start from

RehanChalana avatar Oct 01 '24 06:10 RehanChalana

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.

ascheman avatar Oct 01 '24 06:10 ascheman

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!

RehanChalana avatar Oct 01 '24 14:10 RehanChalana

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.

ascheman avatar Oct 01 '24 14:10 ascheman

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 avatar Oct 01 '24 15:10 RehanChalana