Update NuGet packages and refactor test lifecycle - #7
Conversation
Updated several NuGet packages in `Ais.Net.Models.Specs.csproj` to their latest versions, including `coverlet.msbuild`, `Microsoft.NET.Test.Sdk`, `NUnit3TestAdapter`, `Reqnroll.NUnit`, and `Shouldly`. Added `[NUnit.Framework.FixtureLifeCycleAttribute(NUnit.Framework.LifeCycle.InstancePerTestCase)]` to `AisMessageType18Feature` for improved test fixture management. Refactored `FeatureSetupAsync` and `FeatureTearDownAsync` methods to be static, enhancing test setup practices. Enhanced `TestInitializeAsync`, `ScenarioStartAsync`, and `ScenarioCleanupAsync` methods for better error handling and resource management. Updated `packages.lock.json` to reflect new package versions and modified `Ais.Net.Models.csproj` to upgrade `Endjin.RecommendedPractices.GitHub` from `2.1.13` to `2.1.18`.
Updated `Ais.Net.Models.Specs.csproj` to include new compile and feature item groups for `.feature.cs` and `.feature` files. Introduced nullable types and null checks in `AisMessageType18StepDefinitions.cs` for better data integrity. Added new step definition classes for `AisMessageType19`, `AisMessageType1Through3`, `AisMessageType24Part0`, `AisMessageType24Part1`, `AisMessageType27`, and `AisMessageType5`, each with methods for creating records and validating properties. Corresponding feature files were auto-generated to define scenarios for testing the new message types.
This commit refactors several AIS message type step definition classes to inherit from a new base class `StepDefinitionBase`, introducing a common `Message` property for better management of created AIS messages. The `PositionData` class is updated to use `double` for `Latitude` and `Longitude` for improved precision. A new `CommonStepDefinitions` class is added for shared background steps, and feature files are renamed for clarity, utilizing parameterized examples. Additionally, a `Hooks` class is introduced to handle pre- and post-scenario logic, enhancing the overall structure and maintainability of the tests.
Removed `<None>` elements for settings files and eliminated `<Compile>` and `<ReqnrollFeature>` elements related to feature files. This simplifies the project structure and may streamline the build process.
Test Results0 tests 0 ✅ 0s ⏱️ For more details on these parsing errors, see this check. Results for commit a57d163. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Pull request overview
This PR updates the repo’s build/test toolchain (NuGet package upgrades + locked restore updates), adds/updates Reqnroll/NUnit spec assets (features + step definitions + generated feature fixtures), and migrates the build scaffolding/configuration towards ZeroFailed while adjusting the GitHub Actions workflow to a matrix pipeline.
Changes:
- Bump test/build-related NuGet dependencies (and update
packages.lock.json) and upgradeEndjin.RecommendedPractices.GitHub. - Add new Reqnroll feature files, generated
*.feature.csfixtures, and step definitions for multiple AIS message types; apply per-test-case fixture lifecycle in generated fixtures. - Switch build configuration from
.devopsto.zf(ZeroFailed) and update the CI workflow to a multi-OS test matrix.
Reviewed changes
Copilot reviewed 24 out of 32 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| Solutions/Ais.Net.Models/Ais.Net.Models.csproj | Bumps Endjin.RecommendedPractices.GitHub package version. |
| Solutions/Ais.Net.Models.Specs/StepDefinitionBase.cs | Introduces a shared base class for step definitions to hold the current message under test. |
| Solutions/Ais.Net.Models.Specs/packages.lock.json | Updates locked NuGet dependency graph for the specs project after package upgrades. |
| Solutions/Ais.Net.Models.Specs/Hooks.cs | Adds Reqnroll hook class scaffold for scenario lifecycle integration. |
| Solutions/Ais.Net.Models.Specs/Features/AisMessageType5.feature.cs | Adds generated Reqnroll/NUnit fixture for the new Message Type 5 feature. |
| Solutions/Ais.Net.Models.Specs/Features/AisMessageType5.feature | Adds a BDD feature spec for Message Type 5 decoding. |
| Solutions/Ais.Net.Models.Specs/Features/AisMessageType27.feature.cs | Adds generated Reqnroll/NUnit fixture for the new Message Type 27 feature. |
| Solutions/Ais.Net.Models.Specs/Features/AisMessageType27.feature | Adds a BDD feature spec for Message Type 27 decoding. |
| Solutions/Ais.Net.Models.Specs/Features/AisMessageType24Part1.feature.cs | Adds generated Reqnroll/NUnit fixture for the new Message Type 24 Part 1 feature. |
| Solutions/Ais.Net.Models.Specs/Features/AisMessageType24Part1.feature | Adds a BDD feature spec for Message Type 24 Part 1 decoding. |
| Solutions/Ais.Net.Models.Specs/Features/AisMessageType24Part0.feature.cs | Adds generated Reqnroll/NUnit fixture for the new Message Type 24 Part 0 feature. |
| Solutions/Ais.Net.Models.Specs/Features/AisMessageType24Part0.feature | Adds a BDD feature spec for Message Type 24 Part 0 decoding. |
| Solutions/Ais.Net.Models.Specs/Features/AisMessageType1Through3.feature.cs | Adds generated Reqnroll/NUnit fixture for the new Message Type 1–3 feature. |
| Solutions/Ais.Net.Models.Specs/Features/AisMessageType1Through3.feature | Adds a BDD feature spec for Message Type 1–3 decoding. |
| Solutions/Ais.Net.Models.Specs/Features/AisMessageType19.feature.cs | Adds generated Reqnroll/NUnit fixture for the new Message Type 19 feature. |
| Solutions/Ais.Net.Models.Specs/Features/AisMessageType19.feature | Adds a BDD feature spec for Message Type 19 decoding. |
| Solutions/Ais.Net.Models.Specs/Features/AisMessageType18.feature.cs | Refactors generated fixture to per-test-case lifecycle and aligns it with the updated feature structure/background. |
| Solutions/Ais.Net.Models.Specs/Features/AisMessageType18.feature | Updates the Message Type 18 BDD feature to use a background + scenario outline examples. |
| Solutions/Ais.Net.Models.Specs/CommonStepDefinitions.cs | Adds a shared background step definition used by multiple features. |
| Solutions/Ais.Net.Models.Specs/AisMessageType5StepDefinitions.cs | Adds step bindings implementing the Message Type 5 feature. |
| Solutions/Ais.Net.Models.Specs/AisMessageType27StepDefinitions.cs | Adds step bindings implementing the Message Type 27 feature. |
| Solutions/Ais.Net.Models.Specs/AisMessageType24Part1StepDefinitions.cs | Adds step bindings implementing the Message Type 24 Part 1 feature. |
| Solutions/Ais.Net.Models.Specs/AisMessageType24Part0StepDefinitions.cs | Adds step bindings implementing the Message Type 24 Part 0 feature. |
| Solutions/Ais.Net.Models.Specs/AisMessageType1Through3StepDefinitions.cs | Adds step bindings implementing the Message Type 1–3 feature. |
| Solutions/Ais.Net.Models.Specs/AisMessageType19StepDefinitions.cs | Adds step bindings implementing the Message Type 19 feature. |
| Solutions/Ais.Net.Models.Specs/AisMessageType18StepDefinitions.cs | Refactors step bindings for Message Type 18 to use shared base + table-driven inputs. |
| Solutions/Ais.Net.Models.Specs/Ais.Net.Models.Specs.csproj | Updates test package versions and marks the project explicitly as a test project. |
| build.ps1 | Switches the build bootstrap from Endjin scaffolding to ZeroFailed module initialization and config path. |
| .zf/config.ps1 | Adds ZeroFailed build configuration/tasks entry point for the repository build. |
| .gitignore | Ignores ZeroFailed extensions cache folder. |
| .github/workflows/build.yml | Updates CI workflow to matrix pipeline and changes env var wiring for ZeroFailed publishing configuration. |
| .devops/config.ps1 | Removes the previous Endjin build configuration entry point. |
Files not reviewed (7)
- Solutions/Ais.Net.Models.Specs/Features/AisMessageType18.feature.cs: Generated file
- Solutions/Ais.Net.Models.Specs/Features/AisMessageType19.feature.cs: Generated file
- Solutions/Ais.Net.Models.Specs/Features/AisMessageType1Through3.feature.cs: Generated file
- Solutions/Ais.Net.Models.Specs/Features/AisMessageType24Part0.feature.cs: Generated file
- Solutions/Ais.Net.Models.Specs/Features/AisMessageType24Part1.feature.cs: Generated file
- Solutions/Ais.Net.Models.Specs/Features/AisMessageType27.feature.cs: Generated file
- Solutions/Ais.Net.Models.Specs/Features/AisMessageType5.feature.cs: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| namespace Ais.Net.Models.Specs; | ||
|
|
||
| using System; | ||
|
|
||
| using Reqnroll; | ||
|
|
||
| using Shouldly; |
| namespace Ais.Net.Models.Specs; | ||
|
|
||
| using System; | ||
|
|
||
| using Abstractions; | ||
|
|
||
| using Reqnroll; | ||
|
|
||
| using Shouldly; | ||
|
|
| namespace Ais.Net.Models.Specs; | ||
|
|
||
| using Abstractions; | ||
| using System; | ||
|
|
||
| using Abstractions; |
| namespace Ais.Net.Models.Specs; | ||
|
|
||
| using System; | ||
|
|
||
| using Abstractions; | ||
|
|
||
| using Reqnroll; | ||
|
|
||
| using Shouldly; | ||
|
|
| namespace Ais.Net.Models.Specs; | ||
|
|
||
| using System; | ||
|
|
||
| using Abstractions; | ||
|
|
||
| using Reqnroll; | ||
|
|
||
| using Shouldly; | ||
|
|
| namespace Ais.Net.Models.Specs; | ||
|
|
||
| using System; | ||
|
|
||
| using Reqnroll; | ||
|
|
||
| using Shouldly; | ||
|
|
| namespace Ais.Net.Models.Specs; | ||
|
|
||
| using System; | ||
|
|
||
| using Reqnroll; | ||
|
|
||
| using Shouldly; | ||
|
|
| type: boolean | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.sha }} |
Solution/build: - Convert the solution to .slnx and adopt Central Package Management (Directory.Packages.props); add global.json pinning the .NET 10 SDK and selecting the Microsoft.Testing.Platform test runner. - Multi-target the library and tests to net8.0;net10.0 (non-breaking minor release; net10.0-only planned for the next release). Update CI to the 10.x SDK and test both frameworks. Tests: - Migrate the Reqnroll BDD specs to Microsoft.Testing.Platform unit tests (MSTest.Sdk + Shouldly, NSubstitute in the stack); remove coverlet, which is incompatible with MTP. - Expand coverage to 100% line and branch (245 tests per target framework). Correctness fixes in AisMessageExtensions: - ToShipTypeGroup(49) now maps to HighSpeedCraftNoAdditionalInformation (previously mis-classified as Reserved, disagreeing with the description). - CleanVesselName strips '@'/space padding order-independently and fully collapses runs of interior spaces. - Unify the ship-type group and description into a single lookup table so the two can no longer drift. Performance/allocation: - Span-based CleanVesselName, ReadOnlySpan<byte> GetString, and guarded stackallocs in the text helpers. - Add the Ais.Net.Models.Benchmarks project (BenchmarkDotNet, MemoryDiagnoser). Documentation: - Add XML documentation across the public API, generate the docs file so it ships in the package, and drop the doc-warning suppressions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q3BkmohCNRYGY1RBKbNaCx
- Package failed with NETSDK1127 (the net8.0 targeting pack was missing): the runner only had the .NET 10 SDK. Install the .NET 8 SDK too via additionalNetSdkVersion so net8.0 can be built, tested and packed. - Windows test jobs failed because Microsoft.Testing.Platform test projects build an OS-specific executable, and the pipeline compiles once on ubuntu and shares the binaries cross-OS, so the Windows job cannot launch the Linux test host. Restrict the test matrix to ubuntu-latest (the compile OS); the library is pure managed code, so single-OS testing is sufficient. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q3BkmohCNRYGY1RBKbNaCx
Updated several NuGet packages in
Ais.Net.Models.Specs.csprojto their latest versions, includingcoverlet.msbuild,Microsoft.NET.Test.Sdk,NUnit3TestAdapter,Reqnroll.NUnit, andShouldly.Added
[NUnit.Framework.FixtureLifeCycleAttribute(NUnit.Framework.LifeCycle.InstancePerTestCase)]toAisMessageType18Featurefor improved test fixture management. RefactoredFeatureSetupAsyncandFeatureTearDownAsyncmethods to be static, enhancing test setup practices.Enhanced
TestInitializeAsync,ScenarioStartAsync, andScenarioCleanupAsyncmethods for better error handling and resource management. Updatedpackages.lock.jsonto reflect new package versions and modifiedAis.Net.Models.csprojto upgradeEndjin.RecommendedPractices.GitHubfrom2.1.13to2.1.18.