Skip to content

chore: unified hybrid tests enabled environment var - #4137

Open
NoelStephensUnity wants to merge 10 commits into
develop-3.x.xfrom
chore/unified-hybrid-tests-enabled-environment-var
Open

chore: unified hybrid tests enabled environment var#4137
NoelStephensUnity wants to merge 10 commits into
develop-3.x.xfrom
chore/unified-hybrid-tests-enabled-environment-var

Conversation

@NoelStephensUnity

@NoelStephensUnity NoelStephensUnity commented Aug 20, 2026

Copy link
Copy Markdown
Member

Purpose of this PR


Base branch: chore/enable-unified-hybrid-tests (#4122) — not develop-3.x.x — merge #4122 before this.


Follow-up to #4122, which added the unified (NGO + N4E) hybrid prefab test job. That first step
selected which tests ran by passing a name pattern to UTR (unified_test_filter). This PR replaces
that pattern with test selection defined in C#, so the YAML no longer decides what runs.

This is the first part of 3 PRs:

  1. chore: enable unified hybrid tests #4122 gets the initial scaffolding into place (under review).
  2. chore: unified hybrid tests enabled environment var #4137 (this PR) removes the test filter and uses the UNIFIED_TEST environment variable (almost exactly like CMB service tests with the difference that it is going to start out as a "turned off by default" for all tests and will be an "opt-in". The UniversalNetworkTransformTest is the only opt-in for 4137 ). 4137 also removes a bunch of the YAML comment verbosity along with other script file comments.
  3. Yet to be posted PR that will include more NetworkTransformTests.

What replaces the test filter from 4122. The job now sets UNIFIED_TESTS: "true" and passes no --testfilter
(unified_test_filter is deleted from project.metafile). NetcodeIntegrationTest applies three
rules, all under #if UNIFIED_NETCODE, so nothing changes when N4E is absent:

Test pass Test case Result
non-unified hybrid prefab ignored — IgnoredWithoutUnifiedTestsReason
unified hybrid prefab, not opted in ignored — NotOptedInForUnifiedTestsReason
unified not a hybrid prefab ignored — IgnoredForUnifiedTestsReason
unified hybrid prefab, opted in runs

Supporting pieces:

  • ApplyUnifiedTestFilter(HostOrServer) for tests that take HostOrServer as a test method
    parameter rather than a fixture argument. OneTimeSetup runs once per fixture and cannot see a
    method parameter, so those fixtures call this themselves before starting any instances.
    NetworkVariableTests is the case in this PR.
  • IgnoreIfUnifiedTestsEnvironmentVariableSetAttribute plus
    NetcodeIntegrationTestHelpers.IgnoreIfUnifiedTestsEnvironmentVariableSet() for fixtures that do
    not derive from NetcodeIntegrationTest. The attribute respects RunState.NotRunnable first so it
    cannot resurrect a test another attribute already excluded.
  • USE_CMB_SERVICE always wins. Distributed authority and hybrid prefab spawning cannot be the
    same run, so a CMB service pass forces unified off.
  • The environment variable is read once per test set and reset in OnOneTimeTearDown.
    GetUnifiedTestsEnvironmentVariable() also honours a UNIFIED_TESTS compile define, which is what
    makes a local run possible without setting the variable in the editor's environment.
  • Fixtures that do not need to run against hybrid prefabs now opt out explicitly, each with a comment
    saying to remove the opt-out if the test is later updated to support them.

Also in here: two missing $ prefixes on interpolated Log.Error strings in
NetworkManager.UnifiedIsConfiguredCorrectly, which were logging a literal {nameof(NetCodeConfig)}.

Jira ticket

MTT-XXXX

Changelog

Not relevant — CI and test-infrastructure only. The one runtime edit is an error-message fix in
unified code that is not yet publicly released.

Documentation

  • No documentation changes or additions were necessary.

The reasoning that used to live in the project.metafile comment block now lives with the code it
governs: the UseUnifiedTests and ApplyUnifiedTestFilter XML docs explain why hybrid prefab cases
are opt-in and why a method-parameter HostOrServer needs separate handling.

Testing & QA (How your changes can be verified during release Playtest)

Functional Testing

Manual tests:

  • Manual testing done — runtime tests rebuilt and run locally; the suite is green.

Automated tests:

  • Covered by existing automated tests

The change is itself test infrastructure, so the verification is the shape of the run rather than a
new test: in a unified pass, UnifiedNetworkTransformTest runs and everything else reports as
ignored with one of the three reasons above; in a normal pass, nothing is ignored and the suite
behaves exactly as it did before this PR. Both are visible in the UTR results XML.

Does the change require QA team to:

  • Review automated tests?
  • Execute manual tests?
  • Provide feedback about the PR?

Up-port

Not needed. This targets the #4122 branch on the develop-3.x.x line, and the unified API exists
only there.

Backports

Not needed, same reason.

NoelStephensUnity and others added 8 commits August 16, 2026 15:02
Adding an additional unified hybrid spawning test pass.
Fixed:
- Issue with NetworkObject throwing an exception during hybrid integration test.
- Issue with setting the active world prior to spawning a hybrid prefab during integration tests.
- Issue with UnifiedNetcodeUpdateSystem not overriding the OnCreate method along with checks for a valid NetworkManager and/or transport within OnUpdate.
- Issues (minor) with the original UnifiedNetworkTransformTest.
- Adjustments to the NetcodeIntegrationTest that assures the correct active world is assigned when spawning.
Adding the modified NetcodeConfig specific to NGO.
Adding the unified manifest file for running unified tests.
Unified specific settings
Formatting of the unified test filter.
One more time... just running the UnifiedNetworkTransformTest for this phase.
A more integrated one will be coming in the next PR for this effort.
Co-authored-by: Emma <emma.mcmillan@unity3d.com>
…est filter

Unified selection now lives in C# instead:

- unified-tests.yml sets UNIFIED_TESTS=true and passes no --testfilter;
  unified_test_filter is removed from project.metafile.
- NetcodeIntegrationTest.UseUnifiedTests() (virtual, defaults to false) is the opt-in
  a fixture overrides to run in a unified pass. USE_CMB_SERVICE still takes precedence.
- Adds IgnoreIfUnifiedTestsEnvironmentVariableSetAttribute and the matching
  NetcodeIntegrationTestHelpers.IgnoreIfUnifiedTestsEnvironmentVariableSet() so
  fixtures that do not apply under unified netcode opt out explicitly.
- Applies that opt-out across the package and testproject fixtures that do not need
  to run against hybrid prefabs.
@NoelStephensUnity
NoelStephensUnity marked this pull request as ready for review August 20, 2026 11:52
@NoelStephensUnity
NoelStephensUnity requested review from a team and EmandM as code owners August 20, 2026 11:52
Removed comments regarding unified tests and their dependencies.
@codecov-github-com

codecov-github-com Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

@@                Coverage Diff                @@
##           develop-3.x.x    #4137      +/-   ##
=================================================
- Coverage          78.01%   77.92%   -0.10%     
=================================================
  Files                153      153              
  Lines              26254    26260       +6     
=================================================
- Hits               20483    20463      -20     
- Misses              5771     5797      +26     
Flag Coverage Δ
NGOv2_project_testproject_ubuntu_pinnedTrunk 77.64% <ø> (?)
NGOv2_project_testproject_ubuntu_trunk ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...netcode.gameobjects/Runtime/Core/NetworkManager.cs 79.78% <ø> (ø)
....netcode.gameobjects/Runtime/Core/NetworkObject.cs 75.29% <ø> (ø)

... and 4 files with indirect coverage changes

Components Coverage Δ
com.unity.netcode.gameobjects 77.92% <100.00%> (-0.10%) ⬇️

ℹ️ Need help interpreting these results?

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.

1 participant