Skip to content

Add tests to CropsNH and improve common utilities - #242

Draft
C0bra5 wants to merge 21 commits into
masterfrom
add-functional-tests
Draft

Add tests to CropsNH and improve common utilities#242
C0bra5 wants to merge 21 commits into
masterfrom
add-functional-tests

Conversation

@C0bra5

@C0bra5 C0bra5 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds 2 unit-testing modules to the codebase:

  • The test module allows us to test components that don't require a loaded game.
  • The functionalTest module allows us to test components that require a loaded game.

The common utility improvements mostly come from unit tests revealing odd edge cases, but there are a few improvements here and there since I'll be using this PR to add some things I'm targeting for 2.10, as I'm not planning to merge this PR for 2.9.

Summary of the more notable common utility changes

  • Added a Reference field to know if we're in the regular game env or running unit tests without a loaded game.
  • Meta map now has remove and removeWildcard functions to help remove things during load.
  • SeedStats.DEFAULT_ANALYZED is now SeedStats.DEFAULT_ANALYZED_READONLY, and a constructor that takes only the analyzed status has been added to handle cases where the default value should remain mutable without affecting the readonly instance.
  • When an unknown crop ID is detected, the default fallback crop is now standardized via CropsNHUtils.getFallbackCrop.

Test writing progress

With the introduction of these modules, I'm looking to start by adding unit tests for all the following items:

  • CropsNHUtils.getSeedData
  • CropsNHUtils.isStackValid (and its variation)
  • CropsNHUtils.isStackInvalid (and its variation)
  • CropsNHUtils.copyStackWithSize
  • MetaMap
  • MetaSet
  • CropRegistry
  • SeedData
  • SeedStats
  • CropCard
  • IFDropTable
  • SubSoilRequirement
  • SoilList
  • CompoundSoilList
  • Min/MaxLightLevelRequirement
  • World/MachineOnlyBreeding/GrowingRequirement
  • BootProtectionRegistry
  • ItemPotencyRegistry
  • FluidPotencyRegistry

Checklist

  • I have tested this PR in DevEnv
  • I have tested this PR in Fullpack
  • This PR is in compliance with the GTNH AI Policy
    • No AI used
  • This PR requires another PR in order to merge

@C0bra5 C0bra5 added the Enhancement Improve an existing mechanic. Please explain the change with a before/after comparison. label Aug 13, 2026
@C0bra5
C0bra5 marked this pull request as ready for review August 13, 2026 06:47
@C0bra5
C0bra5 marked this pull request as draft August 13, 2026 06:47
@C0bra5
C0bra5 marked this pull request as ready for review August 13, 2026 06:49
@C0bra5
C0bra5 marked this pull request as draft August 13, 2026 22:05
@C0bra5
C0bra5 marked this pull request as ready for review August 13, 2026 22:09
@C0bra5
C0bra5 marked this pull request as draft August 18, 2026 06:39
@C0bra5

C0bra5 commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator Author

I'll draft this since I'll be adding more tests. This PR wasn't necessarily intended for 2.9, but I'll mark it as frozen for now since the changes will get large enough that it won't be a good idea to merge it into a feature-frozen project going forward.

@C0bra5 C0bra5 changed the title Add functional tests to CropsNH Add tests to CropsNH Aug 18, 2026
@C0bra5 C0bra5 changed the title Add tests to CropsNH Add tests to CropsNH and improve common utilities Aug 18, 2026
@C0bra5 C0bra5 added the Ongoing Freeze - Do NOT Merge PR tagged with this do not meet the requirement to be merged during a freeze. label Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Improve an existing mechanic. Please explain the change with a before/after comparison. Ongoing Freeze - Do NOT Merge PR tagged with this do not meet the requirement to be merged during a freeze.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant