Skip to content

ci: extract environment-dependent unit tests out of browser E2E matrix jobs#3952

Merged
MohabMohie merged 2 commits into
mainfrom
ChaosEngine/3935-extract-env-unit-tests
Jul 21, 2026
Merged

ci: extract environment-dependent unit tests out of browser E2E matrix jobs#3952
MohabMohie merged 2 commits into
mainfrom
ChaosEngine/3935-extract-env-unit-tests

Conversation

@MohabMohie

Copy link
Copy Markdown
Contributor

Summary

  • e2eTests.yml's Ubuntu_Firefox_Grid/Ubuntu_Chrome_Grid/Ubuntu_MicrosoftEdge_Grid jobs run -Dtest=${GLOBAL_TESTING_SCOPE}, and GLOBAL_TESTING_SCOPE was an unfiltered "everything except a short blocklist" selector — so every Mockito-mocked, environment-independent unit test in shaft-engine rode along inside those live-grid JVMs under -DsetParallel=METHODS, three times over (once per browser). This is the structural root cause S2 (E2E Tests grid suites: fix deterministic cross-browser failing unit-test cluster (env-dependent tests inside browser matrix jobs) #3928, PR Fix grid-CI test-isolation and portability bugs (S2) #3936) band-aided with @Test(singleThreaded = true) rather than fixed.
  • Adds 35 individually-verified com.shaft.**.internal unit-test classes (see list below) plus the whole testPackage.unitTests package to GLOBAL_TESTING_SCOPE's exclusion list.
  • Widens pr-gate.yml's existing unit-tests job (shaft-engine leg) to run those same 35 classes, so they keep executing — now in their dedicated non-matrix, path-conditioned home instead of a nightly browser-matrix job. testPackage.unitTests already ran there.

Evidence

Each of the 35 moved classes was checked for real driver/grid/network dependency before moving:

  • Grepped for new (Chrome|Firefox|Remote|Edge|Safari)WebDriver(, localhost:4444, docker, BrowserStack. outside comments — the only hits are inside Mockito.mockConstruction(...) blocks or string-only property values asserted for branch coverage (e.g. DriverFactoryHelperCoverageUnitTest.closeDriverShouldHandleDockerizedExecutionBranch sets executionAddress("dockerized") as a literal string, never touches real Docker).
  • RemoteGridPreflightUnitTest explicitly disables remotePreflightEnabled in @AfterMethod cleanup.
  • ImageProcessingActionsScreenshotBaselineUnitTest uses VisualProcessingProviderRegistry.setProviderForTesting(mock(...)), never the real shaft-visual runtime.
  • AssertionEvidenceReporterTest / FailureTraceReporterTest (flagged as environment-coupling risks by the S2/E2E Tests grid suites: fix deterministic cross-browser failing unit-test cluster (env-dependent tests inside browser matrix jobs) #3928 fix) use a fake in-process WebDriver implementation (RecordingJavascriptExecutorDriver) and Mockito — no real session.
  • All 35 class names were confirmed unique across shaft-engine/src/test/java (no ambiguous -Dtest=SimpleName matches in pr-gate.yml).

Classes moved (e2eTests.yml grid jobs → pr-gate.yml unit-tests job)

DriverFactoryHelperAugmentationUnitTest, DriverFactoryHelperCoverageUnitTest, DriverFactoryHelperStorageStateUnitTest, OptionsManagerCoverageUnitTest, RemoteGridPreflightUnitTest, ActionsCoverageUnitTest, ActionsExceptionDetailsUnitTest, ElementInformationCoverageUnitTest, ElementsHelperCoverageUnitTest, AriaSnapshotHelperUnitTest, MobileAccessibilityTreeConverterUnitTest, AnimatedGifManagerCoverageUnitTest, ImageProcessingActionsReportingUnitTest, ImageProcessingActionsScreenshotBaselineUnitTest, ScreenshotHelperCoverageUnitTest, ScreenshotManagerCoverageUnitTest, LocatorHealthReporterUnitTest, RecordManagerCoverageUnitTest, PlaywrightSessionFactoryStorageStateUnitTest, ShardPartitionerUnitTest, UpdateCheckerUnitTest, LightHouseGenerateReportCoverageUnitTest, PropertiesHelperDownloadRetryUnitTest, PropertyFileManagerInternalUnitTest, AllureManagerCoverageUnitTest, BrowserPerformanceExecutionReportUnitTest, FlakeProfilerUnitTest, ProgressBarLoggerCoverageUnitTest, ValidationsHelperCoverageUnitTest, ValidationsHelperNewPatternCoverageUnitTest, VisualValidationsBuilderUnitTest, WebDriverElementValidationsBuilderAriaSnapshotUnitTest, WebDriverElementValidationsBuilderCoverageUnitTest, AssertionEvidenceReporterTest, FailureTraceReporterTest

plus the whole testPackage.unitTests package (already ran in pr-gate.yml; now also excluded from the grid jobs to stop the redundant/racy triple-execution).

Out of scope (left in place, not touched)

  • com.shaft.**.internal classes not suffixed UnitTest (e.g. HealingActionsIntegrationTest, BrowserStorageStateManagerTest, HttpContractBrowserReplayTest) — not individually verified as environment-independent in this pass; left running in the grid jobs.
  • com.shaft.**.internal.*UnitTest classes whose names already match an existing GLOBAL_TESTING_SCOPE exclusion (Api/Json/etc., e.g. OpenApiCoverageReporterUnitTest, GoogleTinkApiCoverageUnitTest) — already homed in Ubuntu_APIs, untouched.
  • *UnitTest classes outside internal/testPackage.unitTests packages (e.g. AsyncElementActionsCoverageUnitTest, PlaywrightElementActionsUnitTest, AllureListenerCoverageUnitTest) — same racing symptom, but out of this issue's explicitly-scoped pattern; worth a follow-up if the racing recurs.

notify_e2e_tests_failure (PR #3951, S5)

Untouched — no job was renamed or removed, only the GLOBAL_TESTING_SCOPE env var value and pr-gate.yml's existing -Dtest= string changed. Its needs: list still names every real job correctly (verified via yaml.safe_load).

Test plan

  • mvn -pl shaft-engine -am -e test-compileBUILD SUCCESS
  • python3 -c "import yaml; yaml.safe_load(...)" on both edited workflow files — parses cleanly, job lists unchanged
  • Verified all 35 moved class names are unique within shaft-engine/src/test/java (no ambiguous match risk in pr-gate.yml's -Dtest=)
  • Full mvn test grid run not executed locally per repo policy (never run unscoped forked Maven/TestNG runs) — relies on CI (pr-gate.yml unit-tests leg + next e2eTests.yml nightly run) for live confirmation

Closes #3935

…x jobs

e2eTests.yml's Ubuntu_Firefox_Grid/Chrome_Grid/MicrosoftEdge_Grid jobs used
GLOBAL_TESTING_SCOPE as an unfiltered "everything except a short blocklist"
test selector, so every Mockito-mocked unit test in shaft-engine rode along
inside those live-grid JVMs under -DsetParallel=METHODS three times over --
exactly the racing pattern S2 (#3928, PR #3936) band-aided with
@test(singleThreaded = true) rather than fixed at the root.

Excludes testPackage.unitTests (already homed in pr-gate.yml's unit-tests
job) and 35 individually-verified com.shaft.**.internal unit-test classes
(no real WebDriver construction, no Docker/BrowserStack/network
touchpoints -- confirmed via Mockito/mockConstruction usage and absence of
live grid/driver calls) from GLOBAL_TESTING_SCOPE, and adds those same 35
classes to pr-gate.yml's shaft-engine unit-tests leg so they keep running,
just in their dedicated non-matrix home instead.

Closes #3935

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@MohabMohie
MohabMohie enabled auto-merge (squash) July 21, 2026 13:56
MohabMohie added a commit that referenced this pull request Jul 21, 2026
…abilities (#3957)

fix: recognize cross-platform absolute mobile_app paths in Appium capabilities

File.isAbsolute() is host-OS-specific, so a Windows drive-letter mobile_app
path (e.g. C:\Windows\System32\notepad.exe) is misdetected as relative on a
Linux JVM and gets mangled by prepending user.dir -- breaking the Appium
"windows" platform target when SHAFT runs from a non-Windows CI/build
machine. Add an OS-independent isAbsoluteAppPath() check (drive-letter regex
or leading "/") ahead of the File.isAbsolute() fallback in
PropertyFileManager.getAppiumDesiredCapabilities(), so Windows- and
Unix-style absolute paths are left unchanged on any host OS while genuinely
relative paths still resolve against user.dir as before.

Fixes the "Unit Tests (shaft-engine)" CI failure blocking PR #3952:
OptionsManagerCoverageUnitTest.shouldInitializeAppiumCapabilitiesForNativeAndMobileWeb
failed on ubuntu-22.04 with the Windows app path silently rewritten to
"/home/runner/.../shaft-engine/C:\Windows\System32\notepad.exe".


Claude-Session: https://claude.ai/code/session_01NDQpYzvnTbDPYwqDwHQoRz

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@MohabMohie
MohabMohie merged commit 17f5b1f into main Jul 21, 2026
25 checks passed
@MohabMohie
MohabMohie deleted the ChaosEngine/3935-extract-env-unit-tests branch July 21, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Extract environment-dependent unit tests out of browser E2E matrix jobs

1 participant