Skip to content

Skip NetteDatabaseTest when database connection unavailable#152

Merged
f3l1x merged 1 commit into
masterfrom
claude/fix-code-quality-tests-HStIk
May 27, 2026
Merged

Skip NetteDatabaseTest when database connection unavailable#152
f3l1x merged 1 commit into
masterfrom
claude/fix-code-quality-tests-HStIk

Conversation

@ohmyfelix

Copy link
Copy Markdown
Contributor

This change adds a database connectivity check to the NetteDatabaseTest to gracefully skip the test suite when the database is not available, rather than failing with connection errors.

Key changes:

  • Added use Tester\Environment; import to enable test skipping functionality
  • Added a try-catch block that attempts to connect to the test database (MySQL on localhost:13306)
  • If the connection fails with a ConnectionException, the test suite is skipped with an informative message
  • This allows the test suite to run in environments where the database may not be available without causing test failures

Implementation details:

  • The connection check uses the same credentials and database configuration that the tests would use
  • The skip is triggered before the test class is defined, preventing any database-dependent tests from running
  • This is a common pattern for integration tests that depend on external services

https://claude.ai/code/session_01A8V5dTVDGP1CJTsjzfmosR

Newer nette/tester reports "forgets to execute an assertion" when all
test methods are skipped only via setUp's $this->skip(), because that
path does not disable the assertion-count check. Skip at file level via
Tester\Environment::skip() when MySQL is unreachable instead.
@f3l1x f3l1x merged commit 4c46ed7 into master May 27, 2026
12 checks passed
@f3l1x f3l1x deleted the claude/fix-code-quality-tests-HStIk branch May 27, 2026 21:03
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

Successfully merging this pull request may close these issues.

3 participants