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

feat: add require for critical checks #2812

Merged

Conversation

AshutoshKD
Copy link
Contributor

What does this PR do?

Using require for essential checks to ensure that tests do not proceed under invalid assumptions, while assert can be used for less critical checks to gather more information about potential issues.

Suggested Usage of assert and require :-

Critical Checks (Use require):
Use require to check critical conditions that must be true for the test to proceed.
If a require condition fails, the test stops immediately. This prevents any further code from running, which could lead to misleading error messages.

Non-Critical Checks (Use assert):
Use assert to evaluate conditions that are important but not critical for the test's overall success.
If an assert condition fails, the test continues to run, allowing multiple assertions to be evaluated.

Why is it important?

It is important to use require for critical conditions so that if a critical check fails, the test execution halts immediately. This prevents the test from continuing to run subsequent assertions, which may rely on the validity of the failed condition, thereby avoiding misleading error messages and ensuring that only relevant failures are reported. This approach enhances the clarity of test results and facilitates quicker identification of the root cause of issues.

Related issues

Copy link

netlify bot commented Oct 3, 2024

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 263adaa
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/66ff0ab9aec24c00085da30c
😎 Deploy Preview https://deploy-preview-2812--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@AshutoshKD AshutoshKD changed the title add require for critical checks feat: add require for critical checks Oct 3, 2024
Copy link
Member

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@AshutoshKD AshutoshKD marked this pull request as ready for review October 5, 2024 19:06
@AshutoshKD AshutoshKD requested a review from a team as a code owner October 5, 2024 19:06
@mdelapenya mdelapenya self-assigned this Oct 5, 2024
@mdelapenya mdelapenya added chore Changes that do not impact the existing functionality hacktoberfest Pull Requests accepted for Hacktoberfest. labels Oct 5, 2024
@mdelapenya mdelapenya merged commit e41374c into testcontainers:main Oct 5, 2024
118 checks passed
mdelapenya added a commit that referenced this pull request Oct 17, 2024
* main:
  chore: replace 'assert' with 'require' (#2827)
  chore: replace 'assert' with 'require' for critical checks (#2824)
  chore: bump ryuk to latest release (#2818)
  feat: add require for critical checks (#2812)
  chore(deps): bump release-drafter/release-drafter from 5.25.0 to 6.0.0 (#2805)
  feat: add etcd module (#2788)
  feat: add dynamodb-local module (#2799)
  fix(redpanda): wait for (#2794)
  fix(elasticsearch): wait for (#2724)
  chore: update dockercfg module (#2801)
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Oct 18, 2024
* main:
  fix(reaper): refactor to allow retries and fix races (testcontainers#2728)
  chore: update ryuk to 0.10.2 (testcontainers#2833)
  feat: add yugabytedb module (testcontainers#2825)
  fix: update module container struct name and missing imports (testcontainers#2831)
  chore: replace 'assert' with 'require' (testcontainers#2827)
  chore: replace 'assert' with 'require' for critical checks (testcontainers#2824)
  chore: bump ryuk to latest release (testcontainers#2818)
  feat: add require for critical checks (testcontainers#2812)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Changes that do not impact the existing functionality hacktoberfest Pull Requests accepted for Hacktoberfest.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants