Skip to content

Issue: Improve Unit Test Coverage for Generator Core Modules #1803

@AnshumohanAcharya

Description

@AnshumohanAcharya

This issue aims to improve unit test coverage for the AsyncAPI Generator core modules, specifically focusing on generator.js, conditionalGeneration.js, and utils.js.

Current Status

  • Overall Coverage: 60.61% statements
  • Target Coverage: 80%+ statements

Current Coverage by File

  • conditionalGeneration.js: 10.25% (very low)
  • generator.js: 50.81% (core file, needs improvement)
  • utils.js: ~67% (several untested utility functions)

Proposed Changes

1. conditionalGeneration.js (Priority: High)

  • Create comprehensive test file: test/conditionalGeneration.test.js
  • Test all functions: isGenerationConditionMet, conditionalParameterGeneration, conditionalSubjectGeneration, conditionalFilesGenerationDeprecatedVersion, validateStatus
  • Cover edge cases and error paths
  • Target: 100% coverage

2. generator.js (Priority: High)

  • Add tests for getAllParameters (both new and old API paths)
  • Add tests for ignoredDirHandler (conditional generation, .git skipping)
  • Add tests for verifyTargetDir (git repo scenarios)
  • Target: Improve from 50.81% to 65%+

3. utils.js (Priority: Medium)

  • Add tests for untested utility functions: isFilePath, convertMapToObject, isAsyncFunction, registerTypeScript, convertCollectionToObject, getGeneratorVersion, isFileSystemPath
  • Target: Improve from ~67% to 90%+

Expected Outcomes

  • Improved test coverage from 60.61% to 73%+ statements
  • Better code reliability through comprehensive test coverage
  • Easier maintenance with tests documenting expected behavior
  • Foundation for future coverage improvements

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions