refactor(tests): improve data variation in existing tests using factory and fixture system
CI / typecheck (pull_request) Successful in 1m2s
CI / security (pull_request) Successful in 51s
CI / quality (pull_request) Successful in 46s
CI / lint (pull_request) Successful in 3m21s
CI / build (pull_request) Successful in 19s
CI / helm (pull_request) Successful in 23s
CI / unit_tests (pull_request) Successful in 7m6s
CI / e2e_tests (pull_request) Successful in 18m1s
CI / integration_tests (pull_request) Successful in 22m52s
CI / docker (pull_request) Successful in 21s
CI / coverage (pull_request) Successful in 10m58s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 57m25s

Audited 587 existing Behave feature files to identify scenarios with poor data variation (hardcoded or repetitive single values). Prioritized high-impact candidates: ULID validation, NamespacedName validation, project name validation, and skill schema name validation. Created 5 new feature files using Behave's native Scenario Outline + Examples tables as the data variation mechanism (since blocking issues #2760 TestDataFactory and #2765 Centralized Fixture System are not yet implemented):
- features/data_variation_plan_ulid.feature: 33 scenarios covering valid/invalid ULID formats, boundary lengths, illegal characters (I/L/O/U), legacy names, and CLI command validation
- features/data_variation_namespaced_name.feature: 32 scenarios covering valid names, special characters in namespace/name components, boundary lengths
- features/data_variation_project_name.feature: 35 scenarios covering invalid special characters, valid formats, path resolution
- features/data_variation_skill_name.feature: 39 scenarios covering invalid names, tool refs, MCP transports, include names
- features/data_variation_edge_cases.feature: 81 scenarios covering empty/null values, boundary lengths, special characters, and invalid input types across all four domains

All 592 features pass (14636 scenarios), typecheck passes with 0 errors

Key design decisions:
- Used Behave Scenario Outline + Examples tables as the Behave-native data variation approach (pending #2760 and #2765)
- Created new additive feature files rather than modifying existing ones to avoid breaking existing tests
- Verified each scenario against actual implementation behavior before including in Examples tables
- Removed pipe characters from table cells (Behave table delimiter conflict)
- Used "a ValueError should be raised" for Pydantic ValidationError assertions (Pydantic ValidationError IS a ValueError)

Impact:
- Improves data variation coverage in critical test domains without restructuring the existing test suite
- Keeps changes isolated and additive to minimize risk to current tests
- Maintains alignment with ongoing infrastructure work (factory/fixture system) while providing immediate gains

ISSUES CLOSED: #2772
This commit is contained in:
2026-04-05 04:22:46 +00:00
parent bbff42ac9a
commit 36b3212607
5 changed files with 684 additions and 0 deletions
+140
View File
@@ -0,0 +1,140 @@
Feature: Skill schema name validation data variation — Scenario Outline refactoring
As a CleverAgents developer
I want skill schema name validation tests to cover a wide range of inputs
So that edge cases and boundary conditions are systematically exercised
#
# Refactored from skill_schema.feature using Scenario Outline.
# Each Examples table row exercises a distinct validation path.
#
#
# Invalid skill names missing or malformed namespace/name format
#
Scenario Outline: Skill schema rejects invalid namespaced names
Given a skill YAML string with name "<invalid_name>"
When I validate the skill schema expecting failure
Then the skill schema validation should fail
And the skill schema error should mention "namespace/name"
Examples: Names without slash separator
| invalid_name | description |
| invalid-name-no-slash | plain name without namespace |
| noslash | single word without slash |
| justname | another plain word |
| toolname | tool name without namespace |
| a | single character without namespace |
Examples: Names with special characters
| invalid_name | description |
| local/bad name!! | spaces and exclamation marks |
| local/bad@name | at-sign in name |
| local/bad#name | hash in name |
| local/bad name | space in name component |
| local/bad/extra | extra slash (three components) |
| bad ns/name | space in namespace |
| bad@ns/name | at-sign in namespace |
# ─────────────────────────────────────────────────────────────────────────
# Invalid tool reference names
# ─────────────────────────────────────────────────────────────────────────
Scenario Outline: Skill schema rejects invalid tool reference names
Given a skill YAML string with an invalid tool ref name "<invalid_ref>"
When I validate the skill schema expecting failure
Then the skill schema validation should fail
And the skill schema error should mention "namespace/name"
Examples: Invalid tool reference formats
| invalid_ref | description |
| no-slash-tool | tool ref without namespace |
| toolname | plain tool name |
| bad name | tool ref with space |
| bad@tool | tool ref with special character |
| a | single character tool ref |
# ─────────────────────────────────────────────────────────────────────────
# Invalid MCP transport values
# ─────────────────────────────────────────────────────────────────────────
Scenario Outline: Skill schema rejects invalid MCP transport values
Given a skill YAML string with MCP transport "<transport>"
When I validate the skill schema expecting failure
Then the skill schema validation should fail
And the skill schema error should mention "transport"
Examples: Invalid transport values
| transport | description |
| grpc | gRPC transport (not supported) |
| websocket | WebSocket transport (not supported) |
| http | plain HTTP transport (not supported) |
| tcp | TCP transport (not supported) |
| udp | UDP transport (not supported) |
| invalid | completely invalid transport name |
| ftp | FTP transport (not supported) |
| amqp | AMQP transport (not supported) |
# ─────────────────────────────────────────────────────────────────────────
# Invalid include names
# ─────────────────────────────────────────────────────────────────────────
Scenario Outline: Skill schema rejects invalid include names
Given a skill YAML string with an invalid include name "<invalid_include>"
When I validate the skill schema expecting failure
Then the skill schema validation should fail
And the skill schema error should mention "namespace/name"
Examples: Invalid include name formats
| invalid_include | description |
| bad-include | include without namespace |
| justname | plain name without slash |
| bad include | include with space |
| bad@include | include with special character |
# ─────────────────────────────────────────────────────────────────────────
# Valid skill names — accepted formats
# ─────────────────────────────────────────────────────────────────────────
Scenario Outline: Skill schema accepts valid namespaced names
Given a skill YAML string with name "<valid_name>"
When I validate the skill schema
Then the skill schema validation should succeed
And the skill config name should be "<valid_name>"
Examples: Valid namespaced name formats
| valid_name | description |
| local/empty-skill | standard local namespace |
| builtin/read-file | builtin namespace |
| org/my-skill | organization namespace |
| a/b | minimal single-char namespace and name |
| my-org/my-skill-v2 | hyphenated namespace and versioned name |
| ns123/skill456 | namespace and name with numbers |
# ─────────────────────────────────────────────────────────────────────────
# Edge cases — empty and null inputs
# ─────────────────────────────────────────────────────────────────────────
Scenario: Skill schema rejects None YAML string
Given a None skill YAML string
When I validate the skill schema expecting failure
Then the skill schema validation should fail
And the skill schema error should mention "None"
Scenario: Skill schema rejects empty YAML string
Given an empty skill YAML string
When I validate the skill schema expecting failure
Then the skill schema validation should fail
And the skill schema error should mention "empty"
Scenario: Skill schema rejects YAML that is a list instead of a mapping
Given a skill YAML string that is a list
When I validate the skill schema expecting failure
Then the skill schema validation should fail
And the skill schema error should mention "mapping"
Scenario: Skill schema rejects missing name field
Given a skill YAML string missing the name field
When I validate the skill schema expecting failure
Then the skill schema validation should fail
And the skill schema error should mention "name"