ace-test 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.ace-defaults/nav/protocols/agent-sources/ace-test.yml +19 -0
  3. data/.ace-defaults/nav/protocols/guide-sources/ace-test.yml +19 -0
  4. data/.ace-defaults/nav/protocols/tmpl-sources/ace-test.yml +11 -0
  5. data/.ace-defaults/nav/protocols/wfi-sources/ace-test.yml +19 -0
  6. data/CHANGELOG.md +169 -0
  7. data/LICENSE +21 -0
  8. data/README.md +40 -0
  9. data/Rakefile +12 -0
  10. data/handbook/agents/mock.ag.md +164 -0
  11. data/handbook/agents/profile-tests.ag.md +132 -0
  12. data/handbook/agents/test.ag.md +99 -0
  13. data/handbook/guides/SUMMARY.md +95 -0
  14. data/handbook/guides/embedded-testing-guide.g.md +261 -0
  15. data/handbook/guides/mocking-patterns.g.md +464 -0
  16. data/handbook/guides/quick-reference.g.md +46 -0
  17. data/handbook/guides/test-driven-development-cycle/meta-documentation.md +26 -0
  18. data/handbook/guides/test-driven-development-cycle/ruby-application.md +18 -0
  19. data/handbook/guides/test-driven-development-cycle/ruby-gem.md +19 -0
  20. data/handbook/guides/test-driven-development-cycle/rust-cli.md +18 -0
  21. data/handbook/guides/test-driven-development-cycle/rust-wasm-zed.md +19 -0
  22. data/handbook/guides/test-driven-development-cycle/typescript-nuxt.md +18 -0
  23. data/handbook/guides/test-driven-development-cycle/typescript-vue.md +19 -0
  24. data/handbook/guides/test-layer-decision.g.md +261 -0
  25. data/handbook/guides/test-mocking-patterns.g.md +414 -0
  26. data/handbook/guides/test-organization.g.md +140 -0
  27. data/handbook/guides/test-performance.g.md +353 -0
  28. data/handbook/guides/test-responsibility-map.g.md +220 -0
  29. data/handbook/guides/test-review-checklist.g.md +231 -0
  30. data/handbook/guides/test-suite-health.g.md +337 -0
  31. data/handbook/guides/testable-code-patterns.g.md +315 -0
  32. data/handbook/guides/testing/ruby-rspec-config-examples.md +120 -0
  33. data/handbook/guides/testing/ruby-rspec.md +87 -0
  34. data/handbook/guides/testing/rust.md +52 -0
  35. data/handbook/guides/testing/test-maintenance.md +364 -0
  36. data/handbook/guides/testing/typescript-bun.md +47 -0
  37. data/handbook/guides/testing/vue-firebase-auth.md +546 -0
  38. data/handbook/guides/testing/vue-vitest.md +236 -0
  39. data/handbook/guides/testing-philosophy.g.md +82 -0
  40. data/handbook/guides/testing-strategy.g.md +151 -0
  41. data/handbook/guides/testing-tdd-cycle.g.md +146 -0
  42. data/handbook/guides/testing.g.md +170 -0
  43. data/handbook/skills/as-test-create-cases/SKILL.md +24 -0
  44. data/handbook/skills/as-test-fix/SKILL.md +26 -0
  45. data/handbook/skills/as-test-improve-coverage/SKILL.md +22 -0
  46. data/handbook/skills/as-test-optimize/SKILL.md +34 -0
  47. data/handbook/skills/as-test-performance-audit/SKILL.md +34 -0
  48. data/handbook/skills/as-test-plan/SKILL.md +34 -0
  49. data/handbook/skills/as-test-review/SKILL.md +34 -0
  50. data/handbook/skills/as-test-verify-suite/SKILL.md +45 -0
  51. data/handbook/templates/e2e-sandbox-checklist.template.md +289 -0
  52. data/handbook/templates/test-case.template.md +56 -0
  53. data/handbook/templates/test-performance-audit.template.md +132 -0
  54. data/handbook/templates/test-responsibility-map.template.md +92 -0
  55. data/handbook/templates/test-review-checklist.template.md +163 -0
  56. data/handbook/workflow-instructions/test/analyze-failures.wf.md +120 -0
  57. data/handbook/workflow-instructions/test/create-cases.wf.md +675 -0
  58. data/handbook/workflow-instructions/test/fix.wf.md +120 -0
  59. data/handbook/workflow-instructions/test/improve-coverage.wf.md +370 -0
  60. data/handbook/workflow-instructions/test/optimize.wf.md +368 -0
  61. data/handbook/workflow-instructions/test/performance-audit.wf.md +17 -0
  62. data/handbook/workflow-instructions/test/plan.wf.md +323 -0
  63. data/handbook/workflow-instructions/test/review.wf.md +16 -0
  64. data/handbook/workflow-instructions/test/verify-suite.wf.md +343 -0
  65. data/lib/ace/test/version.rb +7 -0
  66. data/lib/ace/test.rb +10 -0
  67. metadata +152 -0
@@ -0,0 +1,170 @@
1
+ ---
2
+ doc-type: guide
3
+ title: Testing Guidelines
4
+ purpose: Testing guidelines overview
5
+ ace-docs:
6
+ last-updated: 2026-02-24
7
+ last-checked: 2026-03-21
8
+ ---
9
+
10
+ # Testing Guidelines
11
+
12
+ ## Goal
13
+
14
+ This guide defines the project's overall testing strategy, outlines best practices for writing effective
15
+ tests, and explains conventions for organizing and executing tests to ensure code quality and reliability.
16
+
17
+ This document outlines general testing strategies and best practices. Project-specific configurations or
18
+ conventions should be documented in `dev-taskflow/testing-guide.md` (if it exists).
19
+
20
+ ## 1. Testing Strategy
21
+
22
+ 1. **Test Types:** Employ a mix of test types appropriate for the project:
23
+ * **Unit Tests:** Test individual classes or methods in isolation. Mock dependencies. Focus on logic
24
+ correctness.
25
+ * **Integration Tests:** Test the interaction between two or more components (e.g., class and its
26
+ dependency, module interactions, API client and service). May involve partial mocking or real
27
+ dependencies in controlled environments.
28
+ * **End-to-End (E2E) / System Tests:** Test complete user flows or system functionalities, often
29
+ interacting with real external dependencies or a fully deployed environment. These are typically
30
+ slower and less frequent.
31
+ * **Performance Tests:** Measure response time, throughput, resource usage under specific conditions
32
+ or load.
33
+ * **Security Tests:** Identify vulnerabilities (e.g., penetration testing, dependency scanning).
34
+
35
+ 2. **Directory Structure:** Organize tests logically, typically mirroring the source code structure.
36
+ *(Example structure - adjust based on project)*
37
+
38
+ ```text
39
+ project-root/
40
+ └── tests/ # Or 'spec/'
41
+ ├── unit/
42
+ │ └── my_module/
43
+ │ └── my_class_tests.ext # Use appropriate extension
44
+ ├── integration/
45
+ │ └── service_integration_tests.ext
46
+ ├── e2e/
47
+ │ └── user_workflow_tests.ext
48
+ ├── performance/
49
+ │ └── load_test.ext
50
+ ├── fixtures/ # Test data files (e.g., YAML, JSON)
51
+ ├── support/ # Test helpers, shared contexts, custom matchers
52
+ │ └── helpers.ext
53
+ └── test_helper.ext # Or 'spec_helper.ext' - Test configuration
54
+ ```
55
+
56
+ *(Refer to `docs/blueprint.md` for the project's actual structure)*
57
+
58
+ 3. **Test Pyramid:** Aim for a healthy test pyramid: many fast unit tests at the base, fewer integration
59
+ tests, and even fewer slow E2E tests at the top.
60
+
61
+ ## 2. Writing Good Tests
62
+
63
+ ### Designing for Testability (Especially with AI)
64
+
65
+ Writing testable code is even more important when using AI, as it simplifies verification and makes it
66
+ easier to guide the AI effectively.
67
+
68
+ * **Explicit Dependencies:** Pass dependencies (services, configurations, clients) into functions or
69
+ classes rather than relying on global state or singletons. This makes mocking easier for unit tests.
70
+ * **Pure Functions:** Prefer functions that always return the same output for the same input and have
71
+ no side effects. These are the easiest to test.
72
+ * **Separate Logic from I/O:** Isolate core business logic from operations that interact with external
73
+ systems (files, network, databases). Test the logic separately from the I/O.
74
+ * **Clear Interfaces:** Define clear, well-documented public interfaces for modules and classes. This
75
+ clarifies boundaries for testing and for AI interaction.
76
+ * **Stateless Components:** Where possible, favor stateless components or functions, as state
77
+ management adds complexity to testing.
78
+
79
+ Following these principles makes it easier to write focused unit tests and provide clearer instructions
80
+ to an AI agent when generating or modifying code.
81
+
82
+ 1. **Clarity:**
83
+ * Use descriptive names for test files, contexts/describe blocks, and individual tests (`it "should..."`).
84
+ * Follow the Arrange-Act-Assert (or Given-When-Then) pattern.
85
+ * Keep tests focused on a single behavior or requirement.
86
+
87
+ 2. **Isolation:**
88
+ * Unit tests should mock dependencies to test the unit in isolation.
89
+ * Ensure tests clean up after themselves (reset state, delete created files/records) to avoid
90
+ interference. Use `before`/`after` hooks carefully.
91
+
92
+ 3. **Reliability:**
93
+ * Avoid flaky tests (tests that pass sometimes and fail others without code changes). Address
94
+ sources of flakiness (e.g., timing issues, race conditions, reliance on unstable external
95
+ factors).
96
+ * Tests should be deterministic.
97
+
98
+ 4. **Maintainability:**
99
+ * Use test helpers, factories, or shared contexts to reduce duplication (DRY).
100
+ * Keep tests updated as the code evolves. Delete tests for removed code.
101
+ * Refactor tests just like production code.
102
+
103
+ ## 3. Test Coverage
104
+
105
+ * **Goal:** Aim for meaningful coverage, not just high percentages. Ensure critical paths, complex
106
+ logic, edge cases, and error handling are tested.
107
+ * **Tools:** Use code coverage tools suitable for your language/framework (e.g., SimpleCov for Ruby,
108
+ `bun test --coverage` for Bun/TS) to identify untested code.
109
+ * **Review:** Analyze coverage reports to find gaps, but don't blindly chase 100%. Some code (e.g.,
110
+ simple getters/setters, third-party library wrappers) may not require dedicated tests. Set
111
+ reasonable project coverage targets.
112
+
113
+ ## 4. Mocking & Stubbing
114
+
115
+ * Use mocking/stubbing libraries appropriate for your stack (e.g., `rspec-mocks`, `jest.fn()`) effectively.
116
+ * **Stubs:** Provide canned answers to method calls. Use when you need to control the return value of
117
+ a dependency.
118
+ * **Mocks:** Set expectations on method calls (e.g., assert a method was called with specific
119
+ arguments). Use sparingly, primarily when testing interactions/collaborations.
120
+ * **External Services:** Use relevant libraries (e.g., `WebMock`+`VCR` for Ruby HTTP requests, `msw`
121
+ for JS) to stub external interactions in unit/integration tests, making them faster and more
122
+ reliable.
123
+
124
+ ## 5. Test Data Management
125
+
126
+ * Use test data factories (e.g., `FactoryBot` for Ruby, fixture libraries in other languages) or
127
+ simple fixtures to create consistent and realistic test data.
128
+ * Use data generation libraries (e.g., `Faker`) to generate realistic-looking fake data.
129
+ * Store larger sets of test data in fixture files (e.g., YAML, JSON) within the test directory (e.g.,
130
+ `tests/fixtures/`).
131
+
132
+ ## 6. Running Tests
133
+
134
+ * To run the full suite use `bin/test`.
135
+ * Provide ways to run specific files or individual tests for faster feedback during development.
136
+ * Integrate tests into the CI/CD pipeline.
137
+
138
+ ## 7. Performance & Thread Safety Testing (If Applicable)
139
+
140
+ * **Benchmarking:** Use benchmarking tools to measure the performance of critical code sections.
141
+ * **Load Testing:** Simulate concurrent users or operations to test system behavior under load.
142
+ * **Concurrency:** Write specific tests to verify thread safety if components are expected to be used
143
+ concurrently (e.g., test shared resources under concurrent access using multiple threads).
144
+
145
+ ## 8. Test Performance Optimization
146
+
147
+ For detailed patterns on test performance optimization including:
148
+ - Performance targets by test layer (Unit <10ms, Integration <500ms, E2E <2s)
149
+ - Composite test helpers (reduce deep nesting)
150
+ - E2E to integration migration ("ONE E2E per file" rule)
151
+ - Subprocess stubbing patterns (Open3, DiffOrchestrator)
152
+ - Sleep stubbing for retry tests
153
+ - Zombie mocks detection and prevention
154
+
155
+ See: [Test Performance Guide](guide://test-performance)
156
+
157
+ ## Related Documentation
158
+
159
+ * Technology-Specific Guides:
160
+ * [Ruby (RSpec) Testing Guide](./testing/ruby-rspec.md)
161
+ * [Ruby (RSpec) Configuration Examples](./testing/ruby-rspec-config-examples.md)
162
+ * [Rust Testing Guide](./testing/rust.md)
163
+ * [TypeScript (Bun) Testing Guide](./testing/typescript-bun.md)
164
+ * [Coding Standards Guide](guide://coding-standards.g)
165
+ * [Quality Assurance Guide](guide://quality-assurance.g) (Test Coverage, CI)
166
+ * [Performance Tuning Guide](guide://performance.g) (Performance Testing)
167
+
168
+ * [Troubleshooting Workflow](guide://debug-troubleshooting.g)
169
+ * Relevant Workflow Instructions: [`work-on-task.wf.md`](wfi://task/work) (includes testing
170
+ guidance), [`analyze-failures.wf.md`](wfi://test/analyze-failures) (for classifying failing tests before changes), [`fix-tests.wf.md`](wfi://test/fix) (for applying fixes using analysis output)
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: as-test-create-cases
3
+ description: Generate structured test cases for features and code changes
4
+ # bundle: wfi://test/create-cases
5
+ # context: no-fork
6
+ # agent: general-purpose
7
+ user-invocable: true
8
+ allowed-tools:
9
+ - Bash(ace-task:*)
10
+ - Bash(ace-bundle:*)
11
+ - Read
12
+ - Write
13
+ - Edit
14
+ argument-hint:
15
+ last_modified: 2026-01-10
16
+ source: ace-task
17
+ skill:
18
+ kind: workflow
19
+ execution:
20
+ workflow: wfi://test/create-cases
21
+
22
+ ---
23
+
24
+ Load and run `ace-bundle wfi://test/create-cases` in the current project, then follow the loaded workflow as the source of truth and execute it end-to-end instead of only summarizing it.
@@ -0,0 +1,26 @@
1
+ ---
2
+ name: as-test-fix
3
+ description: Fix failing automated tests systematically
4
+ # context: no-fork
5
+ # agent: general-purpose
6
+ user-invocable: true
7
+ allowed-tools:
8
+ - Bash(ace-task:*)
9
+ - Bash(ace-bundle:*)
10
+ - Bash(ace-test:*)
11
+ - Read
12
+ - Write
13
+ - Edit
14
+ - Grep
15
+ - Glob
16
+ argument-hint: [test-file-pattern]
17
+ last_modified: 2026-02-24
18
+ source: ace-task
19
+ skill:
20
+ kind: workflow
21
+ execution:
22
+ workflow: wfi://test/fix
23
+
24
+ ---
25
+
26
+ Load and run `ace-bundle wfi://test/fix` in the current project, then follow the loaded workflow as the source of truth and execute it end-to-end instead of only summarizing it.
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: as-test-improve-coverage
3
+ description: Analyze coverage and create targeted test tasks to improve coverage
4
+ user-invocable: true
5
+ allowed-tools:
6
+ - Bash(ace-bundle:*)
7
+ - Bash(ace-test:*)
8
+ - Read
9
+ - Write
10
+ - Edit
11
+ - Grep
12
+ - Glob
13
+ argument-hint: "[package-path] [target-percent]"
14
+ last_modified: 2026-03-21
15
+ source: ace-test
16
+ skill:
17
+ kind: workflow
18
+ execution:
19
+ workflow: wfi://test/improve-coverage
20
+ ---
21
+
22
+ Load and run `ace-bundle wfi://test/improve-coverage` in the current project, then follow the loaded workflow as the source of truth and execute it end-to-end instead of only summarizing it.
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: as-test-optimize
3
+ description: Profile and refactor slow tests to restore fast-loop performance
4
+ # bundle: wfi://test/optimize
5
+ # context: no-fork
6
+ # agent: general-purpose
7
+ user-invocable: true
8
+ allowed-tools:
9
+ - Bash(ace-bundle:*)
10
+ - Bash(ace-test:*)
11
+ - Bash(ace-nav:*)
12
+ - Read
13
+ - Write
14
+ - Edit
15
+ - Grep
16
+ - Glob
17
+ argument-hint: [package | path]
18
+ last_modified: 2026-01-31
19
+ source: ace-test
20
+ integration:
21
+ targets:
22
+ - claude
23
+ - codex
24
+ - gemini
25
+ - opencode
26
+ - pi
27
+ providers: {}
28
+ skill:
29
+ kind: workflow
30
+ execution:
31
+ workflow: wfi://test/optimize
32
+ ---
33
+
34
+ Load and run `ace-bundle wfi://test/optimize` in the current project, then follow the loaded workflow as the source of truth and execute it end-to-end instead of only summarizing it.
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: as-test-performance-audit
3
+ description: Profile tests and document slow cases with actionable fixes
4
+ # bundle: wfi://test/performance-audit
5
+ # context: no-fork
6
+ # agent: general-purpose
7
+ user-invocable: true
8
+ allowed-tools:
9
+ - Bash(ace-bundle:*)
10
+ - Bash(ace-test:*)
11
+ - Bash(ace-nav:*)
12
+ - Read
13
+ - Write
14
+ - Edit
15
+ - Grep
16
+ - Glob
17
+ argument-hint: [package | path]
18
+ last_modified: 2026-01-31
19
+ source: ace-test
20
+ integration:
21
+ targets:
22
+ - claude
23
+ - codex
24
+ - gemini
25
+ - opencode
26
+ - pi
27
+ providers: {}
28
+ skill:
29
+ kind: workflow
30
+ execution:
31
+ workflow: wfi://test/performance-audit
32
+ ---
33
+
34
+ Load and run `ace-bundle wfi://test/performance-audit` in the current project, then follow the loaded workflow as the source of truth and execute it end-to-end instead of only summarizing it.
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: as-test-plan
3
+ description: Create a test responsibility map and coverage plan before writing code
4
+ # bundle: wfi://test/plan
5
+ # context: no-fork
6
+ # agent: general-purpose
7
+ user-invocable: true
8
+ allowed-tools:
9
+ - Bash(ace-bundle:*)
10
+ - Bash(ace-test:*)
11
+ - Bash(ace-nav:*)
12
+ - Read
13
+ - Write
14
+ - Edit
15
+ - Grep
16
+ - Glob
17
+ argument-hint: [feature | package | task]
18
+ last_modified: 2026-01-31
19
+ source: ace-test
20
+ integration:
21
+ targets:
22
+ - claude
23
+ - codex
24
+ - gemini
25
+ - opencode
26
+ - pi
27
+ providers: {}
28
+ skill:
29
+ kind: workflow
30
+ execution:
31
+ workflow: wfi://test/plan
32
+ ---
33
+
34
+ Load and run `ace-bundle wfi://test/plan` in the current project, then follow the loaded workflow as the source of truth and execute it end-to-end instead of only summarizing it.
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: as-test-review
3
+ description: Review tests for layer fit, mock quality, and performance
4
+ # bundle: wfi://test/review
5
+ # context: no-fork
6
+ # agent: general-purpose
7
+ user-invocable: true
8
+ allowed-tools:
9
+ - Bash(ace-bundle:*)
10
+ - Bash(ace-test:*)
11
+ - Bash(ace-nav:*)
12
+ - Read
13
+ - Write
14
+ - Edit
15
+ - Grep
16
+ - Glob
17
+ argument-hint: [paths | PR-number]
18
+ last_modified: 2026-01-31
19
+ source: ace-test
20
+ integration:
21
+ targets:
22
+ - claude
23
+ - codex
24
+ - gemini
25
+ - opencode
26
+ - pi
27
+ providers: {}
28
+ skill:
29
+ kind: workflow
30
+ execution:
31
+ workflow: wfi://test/review
32
+ ---
33
+
34
+ Load and run `ace-bundle wfi://test/review` in the current project, then follow the loaded workflow as the source of truth and execute it end-to-end instead of only summarizing it.
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: as-test-verify-suite
3
+ description: Verify test suite health and enforce performance budgets
4
+ # bundle: wfi://test/verify-suite
5
+ # agent: general-purpose
6
+ user-invocable: true
7
+ allowed-tools:
8
+ - Bash(ace-bundle:*)
9
+ - Bash(ace-test:*)
10
+ - Bash(ace-nav:*)
11
+ - Read
12
+ - Write
13
+ - Edit
14
+ - Grep
15
+ - Glob
16
+ argument-hint: [package | path | mode:quick|standard|deep]
17
+ last_modified: 2026-01-31
18
+ source: ace-test
19
+ integration:
20
+ targets:
21
+ - claude
22
+ - codex
23
+ - gemini
24
+ - opencode
25
+ - pi
26
+ assign:
27
+ source: wfi://test/verify-suite
28
+ steps:
29
+ - name: verify-test-suite
30
+ description: Run package test suites with profiling to verify correctness and performance
31
+ intent:
32
+ phrases:
33
+ - "run tests"
34
+ - "run test suite"
35
+ - "verify tests"
36
+ - "test changes"
37
+ - "check tests"
38
+ tags: [testing, verification, performance]
39
+ skill:
40
+ kind: workflow
41
+ execution:
42
+ workflow: wfi://test/verify-suite
43
+ ---
44
+
45
+ Load and run `ace-bundle wfi://test/verify-suite` in the current project, then follow the loaded workflow as the source of truth and execute it end-to-end instead of only summarizing it.