Skip to content

Test: Standardize Exception Testing Patterns #205

@nickna

Description

@nickna

Description

Standardize exception testing across all test files to use consistent NUnit patterns and improve test reliability.

Phase

Phase 0: Test Technical Debt Cleanup

Epic

Related to #202

Acceptance Criteria

  • Audit all exception testing patterns in test files
  • Standardize on Assert.Throws<T>() pattern
  • Ensure exception messages are validated where appropriate
  • Remove inconsistent exception testing approaches
  • Add missing exception tests for edge cases

Current Inconsistencies

  • Mix of Assert.Throws, try-catch blocks, and ExpectedException attributes
  • Inconsistent validation of exception messages
  • Some tests only check exception type, not message content

Preferred Pattern

// PREFERRED: Modern NUnit pattern
var ex = Assert.Throws<ArgumentNullException>(() => database.AddVector(null));
Assert.That(ex.ParamName, Is.EqualTo("vector"));

// PREFERRED: For async methods
var ex = Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => 
    await database.SearchAsync(query, -1));
Assert.That(ex.Message, Contains.Substring("k must be positive"));

Files to Review

  • All test files with exception testing
  • Focus on argument validation tests
  • Search algorithm parameter validation
  • Database operation error conditions

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions