This document tracks the progress of test coverage improvements for the RIDDL project.
- Total Tests: 573 passing (107 utils + 276 language + 190 passes)
- Platform Coverage: JVM (573 tests) + Native (170 tests) = 743 total tests
- Production Bugs Found and Fixed: 3
- Test Files Created: 4 new test files
- Test Files Improved: 6 files with magic number extraction
- Test Files Removed: 6 experimental files with incorrect API usage
Status: Already complete (existing test suite)
- SeqHelpers: 40 tests covering all edge cases
- StringHelpers: 43 tests covering all edge cases
- Utils module: 107 tests total
- Language parsing: 276 tests total
- Passes/validation: 190 tests total
Status: Complete Date Completed: January 6, 2026
-
ParserEdgeCaseTest.scala (595 lines)
- Location:
language/jvm/src/test/scala/com/ossuminc/riddl/language/parsing/ - Tests: Empty inputs, whitespace-only inputs, very long identifiers/strings, Unicode, boundary values, deeply nested structures, maximum/minimum length inputs
- Coverage: Parser edge cases including line endings (CRLF, LF, mixed)
- Location:
-
ParserErrorRecoveryTest.scala (544 lines)
- Location:
language/jvm/src/test/scala/com/ossuminc/riddl/language/parsing/ - Tests: Malformed input handling, syntax error recovery, invalid token sequences, unclosed delimiters, premature end of input
- Coverage: Error messages quality, multiple errors in single parse, invalid escape sequences
- Location:
-
FileIOErrorTest.scala (370 lines)
- Location:
language/jvm/src/test/scala/com/ossuminc/riddl/language/parsing/ - Tests: Non-existent files, directory instead of file, empty files, whitespace-only files, binary files, very large files (10,000 types), invalid UTF-8, circular includes, deeply nested includes
- Coverage: File I/O error handling, path validation, include file error handling
- Location:
-
IDEIntegrationTest.scala (592 lines)
- Location:
language/jvm/src/test/scala/com/ossuminc/riddl/language/ - Tests: Incremental parsing (user typing simulation), location tracking accuracy, error recovery for partial input, performance under IDE-like load, multi-file project handling
- Coverage: IDE-specific scenarios with performance thresholds
- Location:
- ASTTraversalEdgeCaseTest.scala (tested non-existent Visitor/Folder/Iterator APIs)
- ValidationErrorRecoveryTest.scala (needed major refactoring)
- TypeValidationEdgeCaseTest.scala (API mismatches)
- IncludeAndInteractionValidatorTest.scala (API mismatches)
- OptionsValidationTestMigrated.scala (experimental)
- EntityValidatorRefactoredExample.scala (experimental)
- ValidationFixtures.scala (experimental, circular dependency)
- ValidationFixturesExampleTest.scala (referenced removed trait)
- ConcurrencyTest.scala (incorrect API usage)
- PerformanceRegressionSpec.scala (experimental with errors)
Status: Complete Date Completed: January 6, 2026
Extracted magic numbers to named constants in 6 test files, improving readability and maintainability:
-
IDEIntegrationTest.scala
- Constants: 13 named constants
- Categories: Performance timeouts (7), test data sizes (6), location tracking (2)
- Example:
SINGLE_PARSE_TIMEOUT_MS = 100,VERY_LARGE_FILE_TYPE_COUNT = 1000
-
ParserEdgeCaseTest.scala
- Constants: 6 named constants
- Categories: String/identifier lengths (3), collection sizes (2), nesting depth (1)
- Example:
LONG_IDENTIFIER_LENGTH = 255,LARGE_MODEL_TYPE_COUNT = 1000
-
FileIOErrorTest.scala
- Constants: 2 named constants
- Categories: Large file testing (2)
- Example:
VERY_LARGE_FILE_TYPE_COUNT = 10000,LARGE_FILE_PARSE_TIMEOUT_MS = 30000
-
SeqHelpersTest.scala
- Constants: 3 named constants
- Categories: Large sequence testing (3)
- Example:
LARGE_SEQUENCE_SIZE = 10000,TEST_SEARCH_VALUE = 5000
-
TimerTest.scala
- Constants: 1 named constant
- Example:
TEST_TIMER_RETURN_VALUE = 123
-
RiddlParserInputTest.scala
- Constants: 1 named constant
- Example:
EXPECTED_OFFSET_AT_POSITION_2 = 38
Total Impact: 26 named constants created, ~41 magic number instances eliminated
During comprehensive test development, 3 production bugs were discovered and fixed:
File: utils/shared/src/main/scala/com/ossuminc/riddl/utils/SeqHelpers.scala
Issue: Implementation used indexWhere with confusing logic that failed on edge cases
Fix: Rewrote with simpler while loop: while stack.nonEmpty && !f(stack.top) do { stack.pop() }
Tests: 5 test failures revealed the bug
File: utils/shared/src/main/scala/com/ossuminc/riddl/utils/StringHelpers.scala
Issue: Threw NoSuchElementException when called on empty string
Fix: Added empty check: while result.nonEmpty && f(result.last) do result = result.dropRight(1)
Tests: 2 test failures revealed the bug
File: utils/shared/src/main/scala/com/ossuminc/riddl/utils/StringHelpers.scala
Issue: Threw NullPointerException when case class fields were null
Fix: Added null case handling in pattern matching
Tests: 1 test failure revealed the bug
Tests were reorganized to properly support JVM and Native platforms:
These tests use JVM-specific features (java.nio.file) and were moved to jvm/ directories:
- IDEIntegrationTest.scala
- FileIOErrorTest.scala
- ParserEdgeCaseTest.scala
- ParserErrorRecoveryTest.scala
Tests in jvm-native/ directories run on both JVM and Native:
- All shared test infrastructure
- Parser tests that don't use file I/O
- AST tests
- Basic functionality tests
Result: Native tests now pass cleanly (170 tests) without encountering JVM-specific code
- JVM Tests: 107 passing
- Status: ✅ All tests pass
- Coverage: SeqHelpers, StringHelpers, Timer, Platform utilities
- Bugs Fixed: 3 production bugs found and fixed
- JVM Tests: 276 passing
- Native Tests: 170 passing
- Status: ✅ All tests pass on both platforms
- Coverage: Parsing, AST, Messages, File I/O (JVM only), IDE integration (JVM only)
- New Files: 4 comprehensive test files added
- JVM Tests: 190 passing
- Status: ✅ All tests pass
- Coverage: Validation, Resolution, Symbols, Diagrams
- Files Removed: Experimental ValidationFixtures-based tests
Establish performance baselines(Deferred - PerformanceRegressionSpec removed due to API issues)- Document current performance characteristics
- Identify optimization candidates
- Priority 8: Additional IDE-specific scenarios
- Priority 9: Concurrency and thread safety tests (deferred - API mismatches)
- Priority 10: Performance regression suite (deferred - needs API review)
- API Discovery: Creating tests revealed that several assumed APIs don't exist (Visitor, Folder, Iterator patterns)
- Scala 3 Syntax: New tests must use
then/dokeywords for if/while statements - Platform Separation: JVM-specific features (java.nio.file) must be in
jvm/directories, notjvm-native/ - Test Value: Comprehensive edge case tests found 3 real production bugs
- Maintainability: Extracting magic numbers to named constants significantly improves test readability
- Create TEST-COVERAGE-PROGRESS.md (this file)
- Update CONTRIBUTING.md with test guidelines
- Document performance baseline expectations
- Create test writing guide for new contributors
All test suites verified as of January 6, 2026:
✅ utils/test: 107 tests passing
✅ language/test: 276 tests passing (JVM)
✅ languageNative/test: 170 tests passing (Native)
✅ passes/test: 190 tests passing
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Total: 573 JVM tests + 170 Native tests = 743 total tests passing
Last Updated: January 6, 2026 Maintained by: Claude Code