You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Test milestone year marking behavior and improve testing docs
Add test validating attach_milestone_data\! correctly marks years with
is_milestone=true for assets, flows, and both_years scenarios. Addresses
the magic transformation documented in README for issue #3.
Enhance testing documentation with CLI filtering, TestItem.jl patterns,
and development workflow strategies to support selective test execution.
Closes#3
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-authored-by: Claude Code (claude-sonnet-4-20250514) <[email protected]>
**Filtered Testing**: `julia --project=test test/runtests.jl --tags fast --exclude slow`
42
+
43
+
The test runner supports filtering by:
44
+
45
+
-`--tags tag1,tag2`: Run tests with ALL specified tags
46
+
-`--exclude tag1,tag2`: Skip tests with ANY specified tags
47
+
-`--file filename`: Run tests from files containing substring
48
+
-`--name testname`: Run tests whose name contains substring
49
+
-`--pattern text`: Run tests with name/filename containing pattern
50
+
-`--list-tags`: Show available tags
51
+
-`--help`: Show usage help
42
52
43
53
### Running the main example
44
54
@@ -54,7 +64,7 @@ julia --project=.
54
64
55
65
# Install/update dependencies
56
66
julia --project=. -e 'using Pkg; Pkg.instantiate()'
57
-
julia --project=. -e 'using Pkg; Pkg.resolve()'
67
+
julia --project=. -e 'using Pkg; Pkg.update()'
58
68
```
59
69
60
70
### Documentation
@@ -133,3 +143,95 @@ Key properties are schema-driven but commonly include:
133
143
-`investment_cost`: Cost for commission years
134
144
135
145
All assets require proper milestone and commission data attachment for valid models. The exact required fields depend on the TulipaEnergyModel version being used.
146
+
147
+
### Testing Guidelines
148
+
149
+
The project uses TestItem.jl with tags for selective test execution during development.
150
+
151
+
#### Test Organization
152
+
153
+
-**File naming**: `test/test-[functionality].jl` for focused test suites
154
+
-**Descriptive names**: Test names should clearly state what behavior is being verified
155
+
-**Appropriate tags**: Use `:unit`, `:integration`, `:fast` for filtering during development
156
+
-**Logical grouping**: Group related test scenarios within the same file
157
+
158
+
#### Test Dependencies
159
+
160
+
-**Add to test environment**: New testing dependencies go in `test/Project.toml`
161
+
-**Export in common setup**: Make dependencies available via `test/common.jl`
162
+
-**Follow existing patterns**: Use the established `[CommonSetup]` pattern for shared setup
163
+
164
+
#### Test Content Focus
165
+
166
+
-**Behavior verification**: Test what the code does, not how it does it
167
+
-**Schema compatibility**: Tests should work across different TulipaEnergyModel versions
168
+
-**Full workflow coverage**: Include integration tests that exercise `create_connection()` and complete user workflows
169
+
-**Edge cases**: Test boundary conditions, error scenarios, and data combinations
170
+
-**Self-contained**: Each test should be independent and not rely on execution order
171
+
172
+
## Testing Strategy
173
+
174
+
### Development Workflow
175
+
176
+
**During Development**: Use filtered testing to focus on relevant tests only
177
+
178
+
```bash
179
+
# Test specific functionality during development
180
+
julia --project=test test/runtests.jl --file test-year-data --tags fast
181
+
julia --project=test test/runtests.jl --tags unit,fast --exclude slow
182
+
```
183
+
184
+
**Before Commits**: Run full test suite to ensure no regressions
185
+
186
+
```bash
187
+
julia --project=test test/runtests.jl # All tests via CLI runner
188
+
julia --project=test -e 'using Pkg; Pkg.test()'# Full Pkg.test()
189
+
```
190
+
191
+
### Testing Architecture Patterns
192
+
193
+
#### TestItems Organization
194
+
195
+
-**Strategy-per-testitem**: Create focused testitems for each major component/strategy rather than nested loops
196
+
-**Shared testsnippets**: Use `@testsnippet` for per-test setup (runs each time, variables directly accessible)
197
+
-**Shared testmodules**: Use `@testmodule` for one-time expensive operations like data loading/computation (runs once, accessed via module prefix)
198
+
-**Combined approach**: Use both when needed - testmodules for shared expensive operations, testsnippets for per-test variables
199
+
-**Comprehensive validation**: Each testitem should test multiple aspects (files, dependencies, behavior) in one place
200
+
201
+
#### Pattern Examples
202
+
203
+
**@testsnippet (per-test setup):**
204
+
205
+
```julia
206
+
@testsnippet TestData begin
207
+
tulipa =TulipaData() # Fresh instance each test
208
+
add_asset!(tulipa, :test_asset, :producer)
209
+
end
210
+
211
+
@testitem"Feature works" setup=[CommonSetup, TestData] begin
212
+
@testhaskey(tulipa.graph, :test_asset)
213
+
end
214
+
```
215
+
216
+
**@testmodule (one-time expensive operations):**
217
+
218
+
```julia
219
+
@testmodule SharedAssets begin
220
+
const COMPLEX_TULIPA =create_complex_test_model() # Create once
221
+
const REFERENCE_CONNECTION =create_connection(COMPLEX_TULIPA) # Compute once
222
+
end
223
+
224
+
@testitem"Validation works" setup=[CommonSetup, SharedAssets] begin
0 commit comments