Skip to content

Test Coverage & Expectations

← Scenarios | Next: Code Conventions →


1. Test Architecture

The codec-v2 testing is organized into three layers, each testing a specific component:

┌─────────────────────────────────────────────────────────────┐
│                    Codec Runtime Tests                       │
│  (org.eclipse.fennec.codec - serialization/deserialization) │
│  Tests: End-to-end JSON ↔ EObject roundtrip                   │
└─────────────────────────────────────────────────────────────┘
                              ↓ uses
┌─────────────────────────────────────────────────────────────┐
│               Configuration Merger Tests                     │
│  (org.eclipse.fennec.codec - ConfigurationMerger)         │
│  Tests: Merging configs from Global → EClass → EReference    │
└─────────────────────────────────────────────────────────────┘
                              ↓ uses
┌─────────────────────────────────────────────────────────────┐
│                 Aspect Provider Tests                        │
│  (org.eclipse.fennec.codec.metadata - CodecAspectProvider)   │
│  Tests: Parsing EAnnotations → Aspect objects                │
└─────────────────────────────────────────────────────────────┘

1.1 Layer Responsibilities

LayerProjectWhat It TestsTest Focus
AspectProvidercodec.metadataEAnnotation parsingEach annotation key parsed correctly into Aspect EMF objects
ConfigurationMergercodecConfig hierarchy mergingEReference > EClass > Global > Default override chain
Codec RuntimecodecSerialization/DeserializationJSON output/input matches spec for all config combinations

1.2 Test Commands

bash
# AspectProvider tests (annotation parsing)
./gradlew :org.eclipse.fennec.codec.metadata:test

# Model metadata tests
./gradlew :org.eclipse.fennec.model.metadata:test

# Codec v2 tests (merging + runtime)
./gradlew :org.eclipse.fennec.codec:test

# All v2 tests together
./gradlew :org.eclipse.fennec.codec:test :org.eclipse.fennec.codec.metadata:test :org.eclipse.fennec.model.metadata:test

1.3 Model Metadata Tests

Test Class: DiagnosticContainerTest.javaProject: org.eclipse.fennec.model.metadataSpec Reference: 15-error-handling.md (Section 6.10)

Tests for the DiagnosticContainer interface and MetadataDiagnostic model.

TestDescriptionStatus
testDiagnosticsContainmentOnFeatureMetadataVerify diagnostics can be added to FeatureMetadata
testDiagnosticsContainmentOnClassMetadataVerify diagnostics can be added to ClassMetadata
testDiagnosticsContainmentOnPackageMetadataVerify diagnostics can be added to PackageMetadata
testAllDiagnosticsOnFeatureMetadataallDiagnostics equals diagnostics (no children)
testAllDiagnosticsOnClassMetadataallDiagnostics = own + all feature diagnostics
testAllDiagnosticsOnPackageMetadataallDiagnostics = own + all class allDiagnostics
testDiagnosticContainerIdentifiesSourceContainer of diagnostic is the source element

1.4 Config Spec Tests (NEW)

Project: org.eclipse.fennec.codec.apiPackage: test/org/eclipse/fennec/codec/config/spec/Purpose: Verify configuration classes match spec defaults, constraints, and validation rules.

These tests verify that the immutable config classes (TypeConfig, SuperTypeConfig, DiscriminatorConfig, etc.) correctly implement the spec-defined behavior for:

  • Default values
  • Property merging
  • Validation rules (cross-property constraints)

1.4.1 Test Commands

bash
# Run all codec.api tests (includes config spec tests)
./gradlew :org.eclipse.fennec.codec.api:test

1.4.2 TypeConfig Spec Tests

Test Class: TypeConfigSpecTest.javaSpec Reference: 06-type.md

Test CategoryTestsDescription
Defaults4Verify spec-defined defaults (URI strategy, PLAIN format, etc.)
Validation6Invalid strategy/format combinations produce errors
Merge4Property merging and cascade behavior
Strategy values6Each TypeStrategy value accepted correctly
Format combinations4Strategy × Format matrix validation

1.4.3 SuperTypeConfig Spec Tests

Test Class: SuperTypeConfigSpecTest.javaSpec Reference: 07-supertype.md

Test CategoryTestsDescription
Defaults4Verify spec-defined defaults (disabled, ALL selection, etc.)
Validation5Invalid combinations produce appropriate diagnostics
Merge4Property merging and cascade behavior
Selection values4Each SuperTypeSelection value accepted correctly
Format combinations5Format-dependent default keys

1.4.4 DiscriminatorConfig Spec Tests

Test Class: DiscriminatorConfigSpecTest.javaSpec Reference: 08-discriminator-mapping.md

Test CategoryTestsDescription
Defaults5Verify spec-defined defaults (SKIP fallback, empty mappings)
Validation8Invalid fallback configurations, duplicate mappings
Merge6Type mappings and inline mappings merge correctly
FallbackStrategy6Each fallback strategy behavior verified
Mapping operations4Add/remove/lookup type mappings

1.4.5 Test Naming Convention

Spec tests use the naming pattern: {category}_{whatIsTested}_{expectation}

java
@Test
void defaults_typeStrategyIsUri()
@Test
void validation_noneWithStructuredFormat_producesError()
@Test
void merge_overridesTakesPrecedence()

1.5 Package Migration & Test Structure

The codec migration uses a consistent package structure. Tests follow the same pattern as source code.

1.5.1 Package Structure

Old Package (deprecated)New PackageStatus
o.e.f.codec.api.valueo.e.f.codec.value✅ Migrated
o.e.f.codec.api.diagnostico.e.f.codec.diagnostic✅ Migrated
o.e.f.codec.api.configo.e.f.codec.config✅ Already in new location

1.5.2 Test Location Pattern

Source: src/org/eclipse/fennec/codec/{package}/
Tests:  test/org/eclipse/fennec/codec/{package}/
Spec:   test/org/eclipse/fennec/codec/{package}/spec/  (optional)

1.5.3 Deprecated Test Handling

Deprecated tests are kept as migration reference but disabled:

java
@Deprecated
@Disabled("Migrated to org.eclipse.fennec.codec.{package} - kept for migration reference")
@SuppressWarnings("deprecation")
class OldTest { ... }

1.5.4 Current Test Counts (codec.api)

CategoryActive TestsIgnored Tests
Config (impl + spec)~2800
Value (new)540
Diagnostic (new)760
Value (old, deprecated)040
Diagnostic (old, deprecated)076
Total~603116

2. AspectProvider Test Expectations

Test Class: CodecAspectProviderTest.javaTest Ecore: test-codec-annotations.ecoreSpec Reference: 16-annotation-reference.md

The AspectProvider tests verify that EAnnotations are correctly parsed into Aspect EMF objects. These tests do NOT test configuration merging or runtime behavior.

2.0 Scope Clarification (IMPORTANT)

AspectProvider tests ONLY verify:

  • Each annotation key is parsed correctly into Aspect EMF objects
  • Default values are applied when annotations are missing
  • Invalid keys at wrong EMF levels are ignored

AspectProvider tests do NOT verify:

  • Configuration level merging (Global → EClass → ERef) → belongs in ConfigurationMergerTest
  • Source hierarchy merging (LoadOptions → Resource → Annotation) → belongs in ConfigurationMergerTest
  • Runtime serialization/deserialization behavior → belongs in codec runtime tests

The AspectProvider is a pure parsing layer - it converts EAnnotations to Aspect objects. The merging logic that combines aspects from different levels is handled by the ConfigurationMerger in codec.

2.1 Parsing Tests by Feature

Each annotation key should have a test verifying it's parsed correctly.

Type Configuration (06-type.md)

Annotation KeyTest MethodStatus
typeStrategytestBuildClassAspectWithTypeUriStrategy, testBuildClassAspectWithNameTypeStrategy
typeFormattestBuildClassAspectWithStructuredTypeConfig
typeKeytestBuildClassAspectWithTypeUriStrategy
typeNameKeytestBuildClassAspectWithStructuredTypeConfig
typeSchemaKeytestBuildClassAspectWithStructuredTypeConfig
typeMapIdtestBuildClassAspectWithTypeMapId

SuperType Configuration (07-supertype.md)

Annotation KeyTest MethodStatus
superTypeSerializetestBuildClassAspectWithSuperTypeConfig
superTypeKeytestBuildClassAspectWithSuperTypeConfig
superTypeStrategytestBuildClassAspectWithSingleSuperTypeStrategy
superTypeAsArraytestBuildClassAspectWithSuperTypeAsArrayFalse, testBuildClassAspectWithSuperTypeDefaultAsArrayTrue
superTypeSeparatortestBuildClassAspectWithSuperTypeSeparator, testBuildClassAspectWithSuperTypeDefaultSeparator
superTypeFormattestBuildClassAspectWithStructuredSuperTypeConfig
superTypeSchemaKeytestBuildClassAspectWithStructuredSuperTypeConfig
superTypeNameKeytestBuildClassAspectWithStructuredSuperTypeConfig

Discriminator Mapping (08-discriminator-mapping.md)

Annotation KeyTest MethodStatus
typeDiscriminatorPathtestBuildClassAspectWithDiscriminatorPath
typeDiscriminatortestBuildClassAspectWithDiscriminatorValue
inlineMapping.*testBuildReferenceAspectWithInlineTypeMappings
fallbackStrategytestBuildClassAspectWithFallbackError, testBuildClassAspectWithFallbackSkip, testBuildClassAspectWithExplicitFallbackEClass
fallbackEClasstestBuildClassAspectWithExplicitFallbackEClass, testBuildReferenceAspectWithFallbackConfig

ID Configuration (09-id.md)

Annotation KeyTest MethodStatus
idStrategytestBuildClassAspectWithIdFieldStrategy, testBuildClassAspectWithCombinedIdStrategy
idKeyModevalidConfig_idNoneKeyMode_parsedCorrectly (NONE disables ID per spec)
idFormattestBuildClassAspectWithStructuredIdConfig
idKeytestBuildClassAspectWithIdFieldStrategy
idValueKeytestBuildClassAspectWithIdValueKey
idFeaturestestBuildClassAspectWithCombinedIdStrategy
idSeparatortestBuildClassAspectWithCombinedIdStrategy
idSeparatorKeytestBuildClassAspectWithStructuredIdConfig
idSeparatorSerializetestBuildClassAspectWithStructuredIdConfig
idKeyModetestBuildClassAspectWithStructuredIdConfig
idOnToptestBuildClassAspectWithStructuredIdConfig
idValueReaderNametestBuildClassAspectWithCustomIdReaderWriter
idValueWriterNametestBuildClassAspectWithCustomIdReaderWriter

Reference Configuration (10-reference.md)

Annotation KeyTest MethodStatus
refFormattestBuildReferenceAspectWithRefConfig
refKeytestBuildReferenceAspectWithRefConfig
refTypeKeytestBuildReferenceAspectWithRefConfig
expandtestBuildReferenceAspectWithRefConfig

Feature Configuration (11-feature.md)

Annotation KeyTest MethodStatus
keytestBuildAttributeAspectWithCustomKey, testBuildReferenceAspectWithCustomKey
transienttestBuildAttributeAspectWithTransient, testBuildReferenceAspectWithTransient
serializetestBuildAttributeAspectWithExplicitSerialize, testBuildAttributeAspectWithSerializeFalse, testBuildAttributeAspectSerializeOverridesTransient
serializeNulltestBuildAttributeAspectWithSerializeNull
serializeEmptytestBuildAttributeAspectWithSerializeEmpty
serializeDefaultstestBuildAttributeAspectWithSerializeDefaults
enumSerializationtestBuildAttributeAspectWithEnumLiteralStrategy, testBuildAttributeAspectWithEnumValueStrategy, testBuildAttributeAspectWithEnumNameStrategy
valueReaderNametestBuildAttributeAspectWithValueReader, testBuildAttributeAspectWithBothReaderAndWriter
valueWriterNametestBuildAttributeAspectWithValueWriter, testBuildAttributeAspectWithBothReaderAndWriter

2.2 Invalid Configuration Tests (Keys at Wrong Levels)

These tests verify that annotation keys placed at wrong EMF element levels are ignored (not causing errors, just not applied).

Spec Reference: 16-annotation-reference.md - Invalid Configurations

MisconfigurationTest MethodExpected BehaviorStatus
ref* keys on EClasstestClassIgnoresRefConfigKeysIgnored - refConfig is reference-only
idStrategy/idFeatures on EReferencetestReferenceIgnoresIdConfigKeysIgnored - idConfig is class-only
superType* keys on EReferencetestReferenceIgnoresSuperTypeConfigKeysIgnored - superType is class-only
enumSerialization on EReferencetestReferenceIgnoresEnumSerializationKeyIgnored - enum is attribute-only
inlineMapping.* on EClasstestClassIgnoresInlineMappingKeysIgnored - inlineMapping is reference-only
typeDiscriminator on EReferencetestReferenceIgnoresTypeDiscriminatorKeyIgnored - discriminator value is class-only

Missing Invalid Configuration Tests

The following misconfigurations from the spec are NOT yet tested:

MisconfigurationSpec SectionPriority
typeValueReaderName/WriterName on EReferenceType ConfigMedium
type* keys on EAttributeType ConfigMedium
superType* keys on EAttributeSuperType ConfigMedium
typeDiscriminatorPath on EReferenceDiscriminatorMedium
typeMapId on EReferenceDiscriminatorMedium
id* keys on EAttributeID ConfigMedium
idSeparator/Key/Mode/OnTop/ValueKey on EReferenceID ConfigMedium
metadataMerge/Key on EReferenceMetadataLow
metadata* on EAttributeMetadataLow
ref* on EAttributeReferenceMedium
expand on EAttributeReferenceMedium
ignore*/force* on EClassFeatureLow
key on EClassFeatureLow

3. Configuration Hierarchy Test Expectations

Test Class: ConfigurationMergerTest.java (to be created in codec) Spec Reference: 02-config-resolution.md

3.0 Scope Clarification (IMPORTANT)

ConfigurationMerger tests belong in codec, NOT in codec.metadata.

The ConfigurationMerger is responsible for:

  1. Scope Chain Merging (Horizontal): EReference > EClass > Global > Default
  2. Source Hierarchy Merging (Vertical): Load/Save Options > Resource > Factory > Module > EAnnotation > Default

The AspectProvider in codec.metadata only parses individual EAnnotations into Aspect objects. The ConfigurationMerger in codec then combines these aspects with runtime options to produce the effective configuration.

┌─────────────────────────────────────────────────────────────────────┐
│                          codec                                       │
│  ┌─────────────────────────────────────────────────────────────┐    │
│  │                  ConfigurationMerger                         │    │
│  │  - Merges Global + EClass + ERef aspects                     │    │
│  │  - Applies Load/Save options overrides                       │    │
│  │  - Produces EffectiveConfig for serialization               │    │
│  └─────────────────────────────────────────────────────────────┘    │
│                              ↑ uses                                  │
└──────────────────────────────┼──────────────────────────────────────┘

┌──────────────────────────────┼──────────────────────────────────────┐
│                          codec.metadata                              │
│  ┌─────────────────────────────────────────────────────────────┐    │
│  │                  CodecAspectProvider                         │    │
│  │  - Parses EAnnotations from EClass/EReference/EAttribute     │    │
│  │  - Creates ClassCodecAspect, FeatureCodecAspect objects      │    │
│  │  - Does NOT merge across levels                              │    │
│  └─────────────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────────────┘

3.1 Scope Chain (Horizontal) Tests

Tests must verify the override chain: EReference > EClass > Global > Default

Test Scenario: Type Configuration Override

Given:
  - Global config: typeStrategy=URI
  - EClass (Person) annotation: typeStrategy=NAME
  - EReference (Person.address) annotation: typeStrategy=SCHEMA_AND_TYPE

Expected effective config:
  - For Person root object: NAME (from EClass)
  - For Person.address objects: SCHEMA_AND_TYPE (from EReference)
  - For other objects: URI (from Global)
Test CaseConfig LevelsExpected ResultStatus
Global onlyGlobal: NAMEAll use NAME❌ TODO
EClass overrides GlobalGlobal: URI, EClass: NAMEEClass instances use NAME❌ TODO
EReference overrides EClassEClass: URI, ERef: NAMEReferenced objects use NAME❌ TODO
EReference overrides GlobalGlobal: URI, ERef: NAMEReferenced objects use NAME❌ TODO
Partial override (some keys)EClass: strategy=NAME, ERef: format=STRUCTUREDMerges both❌ TODO
No annotation uses defaultNoneUses built-in default❌ TODO

3.2 Source Hierarchy (Vertical) Tests

Tests must verify: Load/Save Options > Resource > Factory > Module > EAnnotation > Default

Test CaseConfig SourcesExpected ResultStatus
Load options override annotationAnnotation: URI, LoadOption: NAMENAME❌ TODO
Resource config override annotationAnnotation: URI, Resource: NAMENAME❌ TODO
Annotation provides value when no runtimeAnnotation: NAME, no runtimeNAME❌ TODO

3.3 Configuration Hierarchy Test Matrix

For each config property that supports multiple levels (per 16-annotation-reference.md matrices), test:

PropertyGlobalEClassERefEAttrOverride Tests Needed
typeStrategyGlobal→EClass, EClass→ERef
typeFormatGlobal→EClass, EClass→ERef
typeKeyGlobal→EClass, EClass→ERef
idStrategyGlobal→EClass only
idFormatGlobal→EClass, EClass→ERef
idKeyGlobal→EClass, EClass→ERef
refFormatGlobal→ERef only
refKeyGlobal→ERef only
serializeNullGlobal→ERef, Global→EAttr
serializeEmptyGlobal→ERef, Global→EAttr
enumSerializationGlobal→EAttr only

4. Codec Runtime Test Expectations

Test Classes: *SerializationEntryTest.java, *DeserializationEntryTest.javaSpec Reference: Chapters 06-type.md through 14-custom-values.md

4.1 Serialization Tests

For each feature chapter, verify JSON output matches spec examples.

Type Serialization (06-type.md)

StrategyFormatExpected OutputTest Status
URIPLAIN"_type": "http://...#//Person"
NAMEPLAIN"_type": "Person"
SCHEMA_AND_TYPEPLAIN"_type": "...", "_schema": "..."
SCHEMA_AND_TYPESTRUCTURED"_type": { "schema": "...", "type": "..." }
NONE-No _type field

ID Serialization (09-id.md)

StrategyKeyModeFormatExpected OutputTest Status
ID_FIELDID_ONLYPLAIN"_id": "value"
ID_FIELDBOTHPLAIN"_id": "value", "idFeature": "value"
COMBINEDID_ONLYPLAIN"_id": "a-b-c"
COMBINEDID_ONLYSTRUCTURED"_id": { "id": "a-b-c", "separator": "-" }

Reference Serialization (10-reference.md)

FormatExpandExpected OutputTest Status
PLAINfalse"_ref": "/path/to/object"
STRUCTUREDfalse"ref": { "_ref": "...", "_type": "..." }
-trueFull object inline✅ ser, ❌ deser

4.2 Deserialization Tests

For each feature chapter, verify EObjects are correctly created from JSON.

FeatureTest FocusTest Status
Type resolutionURI, NAME, SCHEMA_AND_TYPE strategies
ID deserializationPopulate ID features from _id
Reference resolutionProxy creation, later resolution
Discriminator mappingType lookup from discriminator value
Fallback resolutionERROR, SKIP, FALLBACK strategies❌ TODO

5. Test Models

Ecore ModelProjectPurpose
test-codec-annotations.ecorecodec.metadataAspectProvider parsing tests
test-roundtrip.ecorecodecBasic roundtrip tests
test-advanced.ecorecodecPolymorphism, bidirectional, circular refs
test-discriminator.ecorecodecDiscriminator mapping tests

6. Coverage Gaps & Priorities

6.1 High Priority (Blocking v2 completion)

GapComponentSpec SectionAction
Configuration hierarchy testscodec02-config-resolution.mdCreate ConfigurationMergerTest.java
Fallback strategy testscodec08-discriminator-mapping.mdAdd ERROR/SKIP/FALLBACK deser tests
Missing invalid config testscodec.metadata16-annotation-reference.mdAdd tests per Section 2.2

6.2 Medium Priority

GapComponentSpec SectionAction
expand=true deserializationcodec10-reference.mdImplement + test detached object creation
Feature strictness testscodec16-annotation-reference.mdAdd strictOnUnknown/Missing tests
ignore*/force* testscodec.metadata + codec11-feature.mdReplace deprecated transient/serialize

6.3 Low Priority

GapNotes
Large object graphs (1000+ elements)Performance testing
Concurrent access / thread-safetyMulti-threaded scenarios
Cross-resource referencesMultiple EMF resources

7. Test Naming & Intent Tagging Conventions

Clear test naming and tagging is critical for understanding test intent. This helps both humans and AI agents quickly understand whether a test verifies:

  • Valid configuration (happy path)
  • Misconfiguration (error handling - values should be ignored with diagnostics)
  • Edge cases (boundary conditions)

7.1 Test Class Naming by Intent

Separate tests into classes based on their intent:

Class Name PatternIntentExample
*ValidConfigTestTests for correctly configured annotationsCodecAspectProviderValidConfigTest.java
*MisconfigTestTests for misplaced/invalid annotation keysCodecAspectProviderMisconfigTest.java
*DiagnosticsTestTests for diagnostic/warning collectionAspectDiagnosticsTest.java
*EdgeCaseTestTests for boundary conditionsIdSerializationEdgeCaseTest.java

7.2 Test Method Naming Pattern

Use a naming pattern that immediately reveals intent:

For valid configuration tests:

java
void validConfig_typeStrategyUri_parsedCorrectly()
void validConfig_idFieldStrategy_createsIdConfig()

For misconfiguration tests:

java
void misconfig_typeDiscriminatorPathOnReference_ignoredWithDiagnostic()
void misconfig_typeMapIdOnReference_ignoredWithDiagnostic()
void misconfig_enumSerializationOnReference_ignored()

General pattern:

{intent}_{whatIsTested}_{expectedBehavior}

7.3 Model Tagging with @MISCONFIG and @VALID

Use XML comments with clear tags in test .ecore models:

xml
<!-- @VALID: Demonstrates correct inline mapping configuration on EReference -->
<eClassifiers xsi:type="ecore:EClass" name="PersonWithValidConfig">
  ...
</eClassifiers>

<!-- @MISCONFIG: typeDiscriminatorPath is class-only per spec section 7 -->
<!-- Expected: Value is IGNORED, diagnostic WARNING is added -->
<eClassifiers xsi:type="ecore:EClass" name="ReferenceWithClassOnlyKey">
  <eStructuralFeatures xsi:type="ecore:EReference" name="contacts">
    <eAnnotations source="http://eclipse.org/fennec/codec">
      <details key="typeDiscriminatorPath" value="contactType"/>  <!-- INVALID on EReference -->
    </eAnnotations>
  </eStructuralFeatures>
</eClassifiers>

Tag definitions:

TagMeaningTest Expectations
@VALIDCorrectly configured annotationValues should be parsed and applied to aspect
@MISCONFIGIntentionally misconfigured for testingValues should be ignored, diagnostic should be added
@EDGEEdge case or boundary conditionBehavior depends on test case
@SPEC(section)Tests specific spec functionalityCombine with @VALID or @MISCONFIG, reference spec section
@HELPERTests for helper/utility codeUnit tests for utility methods, no spec reference needed

Combining tags:

Tags can be combined to provide full context:

xml
<!-- @SPEC(08-discriminator-mapping.md#7) @MISCONFIG: typeDiscriminatorPath is class-only -->
<!-- Expected: Value is IGNORED, diagnostic WARNING is added -->
<eClassifiers xsi:type="ecore:EClass" name="ReferenceWithClassOnlyKey">
  ...
</eClassifiers>

<!-- @SPEC(06-type.md#2) @VALID: URI type strategy configuration -->
<eClassifiers xsi:type="ecore:EClass" name="PersonWithTypeUri">
  ...
</eClassifiers>

In Java test classes:

java
/**
 * @SPEC(08-discriminator-mapping.md#7) @MISCONFIG
 * Tests that typeDiscriminatorPath on EReference is ignored with diagnostic.
 */
@Test
void misconfig_typeDiscriminatorPathOnReference_ignoredWithDiagnostic() { ... }

/**
 * @HELPER Tests enum parsing utility.
 */
@Test
void parseEnumValue_validInput_returnsEnum() { ... }

7.4 Misconfiguration Test Assertions

Every @MISCONFIG test MUST verify two things:

  1. Value is NOT applied:

    java
    assertNull(aspect.getTypeConfig(),
        "typeConfig should be null - typeDiscriminatorPath is class-only");
  2. Diagnostic is added:

    java
    assertEquals(1, aspect.getDiagnostics().size(),
        "Should have one diagnostic for ignored typeDiscriminatorPath");
    assertEquals("typeDiscriminatorPath", aspect.getDiagnostics().get(0).getKey());
    assertEquals(DiagnosticSeverity.WARNING, aspect.getDiagnostics().get(0).getSeverity());

7.5 Valid/Misconfig Test Pairing

For every @VALID test, verify corresponding @MISCONFIG tests exist.

This ensures complete coverage: if a feature works correctly when configured properly, we must also verify it's handled correctly when misconfigured.

Valid TestRequired Misconfig Tests
@VALID typeStrategy on EClass@MISCONFIG typeStrategy on EAttribute (if invalid there)
@VALID typeDiscriminatorPath on EClass@MISCONFIG typeDiscriminatorPath on EReference
@VALID enumSerialization on EAttribute@MISCONFIG enumSerialization on EReference
@VALID refFormat on EReference@MISCONFIG refFormat on EClass

Review checklist:

  • [ ] For each @VALID annotation key test, check if the key is level-restricted (see 16-annotation-reference.md matrices)
  • [ ] If level-restricted, verify @MISCONFIG tests exist for invalid levels
  • [ ] Report missing misconfig coverage in test strategy feedback

7.6 Why This Matters

Without clear intent markers:

  • Tests like testBuildReferenceAspectWithInlineTypeMappings are ambiguous - is it testing valid config or misconfiguration?
  • When tests fail, it's unclear if the fix should make the value appear or verify it's ignored
  • AI agents may "fix" tests incorrectly by making invalid values pass

With clear intent markers:

  • misconfig_typeDiscriminatorPathOnReference_ignoredWithDiagnostic immediately reveals: this tests error handling
  • Model comment <!-- @MISCONFIG: ... --> confirms the annotation is intentionally wrong
  • Test failure investigation knows to check: is the value ignored? is the diagnostic added?

8. Adding New Tests

7.1 AspectProvider Tests (annotation parsing)

  1. Add test class to test-codec-annotations.ecore
  2. Add test method to CodecAspectProviderTest.java
  3. Follow naming: testBuild[Class|Attribute|Reference]AspectWith[Feature]
  4. Update this document's Section 2

7.2 Configuration Merger Tests

  1. Add test to ConfigurationMergerTest.java
  2. Test both scope chain and source hierarchy
  3. Update this document's Section 3

7.3 Codec Runtime Tests

  1. Add test to appropriate *EntryTest.java class
  2. Reference spec section in test Javadoc
  3. Update this document's Section 4

8. Test Agent Instructions

For test-runner agent: When investigating test failures, consult this document to understand:

  • Which component the test belongs to (Section 1)
  • What the test is supposed to verify (Sections 2-4)
  • Whether the failure indicates a spec gap or implementation bug

For spec-validator agent: Use Sections 2-4 to verify implementation matches spec expectations.


9. Test Strategy Feedback Loop

This document is a living document that evolves based on feedback from test runs.

9.1 Feedback Flow

┌─────────────────────┐
│  test-runner agent  │
│  runs tests         │
└──────────┬──────────┘


┌─────────────────────┐
│  Evaluates strategy │
│  against this doc   │
└──────────┬──────────┘


┌─────────────────────┐
│  Reports findings   │
│  + suggestions      │
└──────────┬──────────┘


┌─────────────────────┐
│  User reviews &     │
│  approves changes   │
└──────────┬──────────┘


┌─────────────────────┐
│  This document is   │
│  updated            │
└─────────────────────┘

9.2 Types of Feedback Expected

Feedback TypeExampleAction
Missing Coverage"Spec defines fallbackStrategy but no test exists"Add to Section 2/3/4 tables
Redundant Tests"Tests A and B verify the same thing"Consolidate in tables
Unclear Expectations"What should happen when X?"Clarify in spec + add test expectation
Better Organization"These tests should be grouped by feature"Restructure tables
New Invalid Configs"Spec says X is invalid but not tested"Add to Section 2.2

9.3 Changelog

Track major changes to test expectations here:

DateChangeReason
2026-01-24Initial restructureSeparated test layers, added matrices
2026-01-24Added fallback testsNew attributes idValueKey, fallbackStrategy, fallbackEClass
2026-01-24Added scope clarificationsClarified that level merging tests belong in ConfigurationMerger (codec), not AspectProvider (codec.metadata)
2026-02-08Added Section 10: Cross-Project Test SummaryComprehensive test inventory across all codec projects

10. Cross-Project Test Summary

This section provides a comprehensive overview of tests across all codec-related projects, including specialized codecs (GeoJSON, JSON Schema, OpenAPI).

10.1 Test Inventory by Project

ProjectTest Files@Test Methods@Nested ClassesQuality Rating
org.eclipse.fennec.codec.api381,039168Excellent
org.eclipse.fennec.codec1081,058276Excellent
org.eclipse.fennec.codec.metadata725558Excellent
org.eclipse.fennec.codec.jsonschema610130Good
org.eclipse.fennec.model.metadata37714Excellent
org.eclipse.fennec.codec.openapi117530Good
org.eclipse.fennec.codec.geojson23414Good
TOTAL1752,639590

10.2 Test Categories by Project

10.2.1 codec.api (Configuration & Value Registry)

Core configuration classes and value reader/writer registry.

CategoryTest ClassesFocus
Config RecordsTypeConfigTest, IdConfigTest, SuperTypeConfigTest, ReferenceConfigTest, FeatureConfigTest, DiscriminatorConfigTestImmutable config creation, defaults, merging
Config Spec*ConfigSpecTest (6 files)Spec compliance: defaults, validation, constraints
Config ResolverConfigurationResolverTest, *ResolverSpecTest (7 files)3D resolution: scope × source × direction
Value RegistryCodecValueRegistry*Test (11 files)Reader/writer registration, lookup, lifecycle
DiagnosticsDiagnosticCollectorTest, CodecDiagnosticTestError/warning collection, EMF integration

10.2.2 codec (Core Serialization/Deserialization)

Main codec implementation with comprehensive entry-level and integration tests.

CategoryTest ClassesFocus
Type HandlingTypeSerializationEntryTest, TypeDeserializationEntryTest, TypeResolutionHelperTest, TypeResolutionHintTest, TypeResolutionUriTest, TypeStrategyContainmentTestAll TypeStrategy values, smart compression
ID HandlingIdSerializationEntryTest, IdDeserializationEntryTestID_FIELD, COMBINED strategies, keyMode
SuperTypeSuperTypeSerializationEntryTest, SuperTypeDeserializationEntryTestHierarchy serialization, validation
ReferencesReferenceSerializationEntryTest (4), ReferenceDeserializationEntryTest (4), PlainReferenceFormatTest, ExpandReferenceTestPLAIN/STRUCTURED formats, expand, proxies
AttributesAttributeSerializationEntryTest (3), AttributeDeserializationEntryTest (3), ArrayAttributeSerializationTest, ArrayAttributeDeserializationTestAll data types, arrays, enums
EMapEMapSerializationTest, EMapDeserializationTest, EMapRoundtripTest, EMapHelperTestMap-as-object, map-as-array
ContextCodecReadContextTest (12), CodecWriteContextTest (10), ContextHelperTest, EMFContextHolderTestJackson context integration, EMF state
ResourceCodecResource*Test (15+)End-to-end roundtrip, cross-package, custom values
DiscriminatorCodecResourceInlineMappingTest, CodecResourceMappedTypeTest, DeserializationModeTestInline mapping, type mapping registry, fallback
IntegrationFeatureVisibilityIntegrationTest, StrictnessIntegrationTest, ForceReadWriteTest, GlobalIgnoreFeatureTestCross-cutting concerns

10.2.3 codec.metadata (Aspect Provider & Discriminator Service)

Annotation parsing and type discriminator services.

CategoryTest ClassesFocus
Aspect ProviderCodecAspectProviderValidConfigTest, CodecAspectProviderMisconfigTestAnnotation parsing, invalid config handling
DiscriminatorTypeDiscriminatorServiceTest, TypeDiscriminatorRegistryTest, TypeDiscriminatorIntegrationTestRegistry management, resolution, fallback
ConstantsCodecAnnotationConstantsTestKey/source definitions
ProfileCodecProfileBuildTestProfile construction

10.2.4 model.metadata (EMF Metadata Model)

Core metadata model and services.

CategoryTest ClassesFocus
DiagnosticsDiagnosticContainerTestDiagnostic containment hierarchy
IndexMapBasedMetadataIndexTestMetadata indexing, lookup
ServiceMetadataServiceImplTestPackage registration, aspect providers

10.2.5 codec.jsonschema (JSON Schema ↔ EPackage)

Bidirectional JSON Schema conversion.

CategoryTest ClassesFocus
ConversionJsonSchemaResourceTest, SchemaMapConversionTest, NewFeaturesTestEPackage ↔ JSON Schema roundtrip
DiagnosticsJsonSchemaDiagnosticsTestConversion warnings, unsupported features
Real-worldRealWorldSchemaTestKubernetes, complex schemas
Value HandlersEPackageValueHandlerTestCustom EPackage serialization

10.2.6 codec.openapi (OpenAPI 3.x Support)

OpenAPI document handling with schema conversion.

CategoryTest ClassesFocus
Document PartsOpenApiInfoTest, OpenApiServersTest, OpenApiSecurityTest, OpenApiTagsTest, OpenApiOperationTestEach OpenAPI section
SchemasOpenApiSchemaTest, OpenApiSchemaDefaultTestSchema types, default values
ReferencesOpenApiRefHandlingTest$ref resolution
IntegrationOpenApiResourceTest, OpenApiRoundtripAnalysisTestFull document roundtrip
Edge CasesOpenApiUnsupportedFeaturesTestGraceful degradation

10.2.7 codec.geojson (GeoJSON Support)

GeoJSON geometry types.

CategoryTest ClassesFocus
GeometriesGeoJsonResourceTestPoint, LineString, Polygon, Multi*, BoundingBox
Force WriteForceWriteTestVolatile feature handling

10.3 Test Quality Assessment (Code Review 2026-02-08)

ProjectFQCN IssuesImport IssuesJava 17 UsageMemory SafetyThread SafetyOverall
codec.apiNoneNoneExcellentExcellentExcellent✅ Excellent
codec2 (fixed)NoneExcellentExcellentExcellent✅ Excellent
codec.metadataNoneNoneExcellentExcellentExcellent✅ Excellent
model.metadataNoneNoneExcellentExcellentExcellent✅ Excellent
codec.jsonschemaNoneNoneGoodGoodN/A✅ Good
codec.openapi2 (fixed)1 (fixed)ExcellentGoodN/A✅ Good
codec.geojsonNoneNoneExcellentGoodN/A✅ Good

Issues Fixed (2026-02-08):

  • OpenApiSchemaDefaultTest.java: FQCN for java.util.Map, java.util.List → Added imports
  • ArrayAttributeDeserializationTest.java: FQCN for EDataType → Added import
  • CodecJsonReadContextReuseTest.java: FQCN for EObject, EStructuralFeature → Added imports
  • package-info.java (codec.openapi): Missing EPL-2.0 license header → Added

10.4 Test Commands Reference

bash
# Run all tests for a specific project
./gradlew :org.eclipse.fennec.codec.api:test
./gradlew :org.eclipse.fennec.codec:test
./gradlew :org.eclipse.fennec.codec.metadata:test
./gradlew :org.eclipse.fennec.model.metadata:test
./gradlew :org.eclipse.fennec.codec.jsonschema:test
./gradlew :org.eclipse.fennec.codec.openapi:test
./gradlew :org.eclipse.fennec.codec.geojson:test

# Run all codec tests together (excluding OSGi tests)
./gradlew :org.eclipse.fennec.codec.api:test \
          :org.eclipse.fennec.codec:test \
          :org.eclipse.fennec.codec.metadata:test \
          :org.eclipse.fennec.model.metadata:test \
          :org.eclipse.fennec.codec.jsonschema:test \
          :org.eclipse.fennec.codec.openapi:test \
          :org.eclipse.fennec.codec.geojson:test

# Run specific test class
./gradlew :org.eclipse.fennec.codec:test --tests "TypeSerializationEntryTest"

# Run tests matching pattern
./gradlew :org.eclipse.fennec.codec:test --tests "*Roundtrip*"

10.5 Test Conventions Applied

All test files follow these conventions (verified 2026-02-08):

ConventionStatusNotes
EPL-2.0 license headers✅ All filesFixed 1 missing header in codec.openapi
No FQCN in code✅ All filesFixed 4 occurrences across 3 files
No wildcard imports✅ All filesExcept package-info.java (acceptable)
Java 17 pattern matching✅ Widely usedif (x instanceof Type t)
Text blocks for JSON✅ Widely usedMulti-line test data
@Nested for organization✅ All projects590 nested classes total
@DisplayName annotations✅ All projectsClear test descriptions
Proper @BeforeEach/@AfterEach✅ All projectsResource cleanup

Next: Code Conventions →

Released under the EPL-2.0 License. Eclipse Fennec is part of the Eclipse Foundation.