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
Add comprehensive unit test suite with 237 tests across 13 test classes
This commit introduces extensive test coverage for the railway interlocking simulator:
**Test Coverage:**
- Utility tests (204 tests): Doubleton, EnumUnorientedGraph, HashMapGraph, TreeMultiMap
- Context tests (10 tests): DefaultContext operations, concurrent XML serialization
- Simulation tests (16 tests): Train behavior, InOutWorker, ShuntingLoop scenarios
- XML tests (7 tests): XMLContextFactory parsing and validation with 10 fixture files
**Test Infrastructure:**
- MockSimulationContext: Mock implementation for isolated testing
- TestContextBuilder: Fluent API for building test contexts
- TestFixtures: Shared test data and configurations
- TestTrackBuilder: Simplified track layout construction
**Build Enhancements:**
- Mockito 5.7.0 integration for mocking framework
- Test resources directory support in build.xml
- JUnit assertions enabled (-ea flag)
- XML test result reporting
**Source Code Fixes:**
- DefaultContext.moveCell: Implement cell movement logic
- XMLContextFactory.saveContext: Fix isolated node serialization
- Train/InOutWorker: Add null pointer validation
- Doubleton/TreeMultiMap: Add deprecation notices
**Documentation Updates:**
- CLAUDE.md: Update test coverage documentation (237 tests, 13 classes)
- Package structure: Add testutil and test fixtures sections
- Test utilities: Document builders and mock implementations
All tests pass with `ant test`. This establishes a strong foundation for maintaining code quality while preserving the legacy 2007 codebase.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@@ -317,17 +332,42 @@ This is a working historical codebase from 2007. Stability and preservation are
317
332
318
333
## Testing
319
334
320
-
JUnit 5.10.1 tests with AssertJ assertions located in `src/test/java/cz/vutbr/fit/interlockSim/`. All dependencies are managed via Apache Ivy.
335
+
Comprehensive JUnit 5.10.1 test suite with AssertJ assertions located in `src/test/java/cz/vutbr/fit/interlockSim/`. All dependencies are managed via Apache Ivy.
321
336
322
337
**Test framework:**
323
338
- JUnit 5 (Jupiter API and Engine)
324
339
- JUnit Platform for Ant integration
325
340
- AssertJ 3.24.2 for fluent assertions
326
341
327
-
**Current tests:**
342
+
**Test coverage (237 tests across 13 test classes):**
343
+
344
+
**Utility tests:**
328
345
-`Array2DMapTest` - 10 tests for 2D array-based map implementation
329
-
-`CellTest` - 2 tests for cell segment and direction logic
330
-
-`ContextTest` - 4 tests for railway network context operations
346
+
-`DoubletonTest` - 66 tests for immutable ordered pair data structure
347
+
-`EnumUnorientedGraphTest` - 55 tests for enum-based unoriented graph
348
+
-`HashMapGraphTest` - 48 tests for HashMap-based graph implementation
349
+
-`TreeMultiMapTest` - 25 tests for tree-based multimap implementation
350
+
351
+
**Context tests:**
352
+
-`DefaultContextTest` - 8 tests for railway network context operations
353
+
-`ConcurrentSaveTest` - 2 tests for thread-safe XML serialization
354
+
355
+
**Simulation tests:**
356
+
-`TrainTest` - 6 tests for train behavior and state management
357
+
-`InOutWorkerTest` - 8 tests for entry/exit point worker operations
358
+
-`ShuntingLoopTest` - 2 tests for shunting loop simulation scenario
359
+
360
+
**XML tests:**
361
+
-`XMLContextFactoryTest` - 7 tests for XML parsing and validation with 10 fixture files
362
+
363
+
**Test utilities:**
364
+
-`MockSimulationContext` - Mock implementation for testing
365
+
-`TestContextBuilder` - Fluent builder for test contexts
366
+
-`TestFixtures` - Shared test data and configurations
367
+
-`TestTrackBuilder` - Fluent builder for test track layouts
368
+
369
+
**Test resources:**
370
+
-`src/test/resources/cz/vutbr/fit/interlockSim/xml/fixtures/` - 10 XML test fixtures for parser validation
0 commit comments