Skip to content

updates unit tests and adds github action ci support#113

Merged
brynrhodes merged 3 commits intomasterfrom
feature/improve-unit-tests
Mar 11, 2026
Merged

updates unit tests and adds github action ci support#113
brynrhodes merged 3 commits intomasterfrom
feature/improve-unit-tests

Conversation

@raleigh-g-thompson
Copy link
Copy Markdown
Contributor

closes #111

PR: Improve unit test coverage, remove Spring from test suite

Branch: feature/improve-unit-tests

Why remove Spring Boot from tests?

Two reasons, one tactical and one strategic.

Tactical: @SpringBootTest spins up the full application context for each
test class. That's unnecessary overhead when you only need to test a single
provider or service. Direct instantiation is faster and makes dependencies
explicit — you can see exactly what a class needs without Spring's wiring hiding
it.

Strategic: The ongoing Kotlin migration (Phase 4) deletes ServerConfig and
PluginConfig and replaces Spring DI with manual wiring in main.kt. Once
Spring is gone from the production code, @SpringBootTest tests can't work at
all. Migrating the tests now means they won't break when Phase 4 lands — and it
unblocks deleting TestConfig.java rather than carrying it forward as dead
weight.

HoverProviderTest was already written the right way (direct instantiation, no
Spring). LanguageServerTest and DiagnosticsServiceTest were the two
stragglers.


Overview

Removes the last two Spring Boot test dependencies in ls/server/, adds a new
FormattingProvider test class, and expands coverage for DiagnosticsService,
HoverProvider, and ExpressionTrackBackVisitor. Net result: 163 → 165 tests,
zero Spring annotations remaining in ls/server/ test sources.


Files Deleted

LanguageServerTest.java
All three hover tests were identical to the existing HoverProviderTest tests.
The fourth test (handshake) only asserted assertNotNull(server). The class
comment itself said "just sketching out some tests here." Removing it eliminates
duplication and a Spring dependency with no coverage loss.

config/TestConfig.java
Only existed to wire a TestContentService bean for the two Spring-based tests.
With both of those tests migrated to direct instantiation, TestConfig has no
remaining callers and can be deleted.


Files Modified

DiagnosticsServiceTest.java

  • Removed @SpringBootTest(classes = {TestConfig.class}) and @Autowired
  • Added @BeforeAll with direct instantiation:
    ContentService cs = new TestContentService();
    CqlCompilationManager mgr = new CqlCompilationManager(cs, new CompilerOptionsManager(cs), new IgContextManager(cs));
    diagnosticsService = new DiagnosticsService(CompletableFuture.completedFuture(mock(LanguageClient.class)), mgr, cs);
  • Retained existing missingInclude test (unchanged)
  • Added validCql_noErrors: lints Two.cql, asserts result contains the URI key
    with an empty diagnostic set
  • Added syntaxError_returnsDiagnostic: lints new SyntaxError.cql fixture,
    asserts at least one diagnostic with severity ERROR

provider/HoverProviderTest.java

  • Added hoverOnLibraryRef: position (5, 8) is 'O' in One."One" on line 5
    (0-indexed) of Two.cql — expects System.Integer (library-qualified reference
    resolves to the expression type)
  • Added hoverOnDefineName: position (4, 8) is 'T' inside define "Two":
    ExpressionDef TrackBack covers the define header, expects System.Integer

visitor/ExpressionTrackBackVisitorTest.java

  • Added positionInExpressionRef_returnsExpressionDef: TrackBack (12, 5, 12, 25)
    covers the "ObservationRetrieve" ExpressionRef inside the ObservationReference
    define — asserts result is an ExpressionDef
  • Added positionAtExpressionBoundary_returnsExpressionDef: TrackBack (15, 5, 15, 5)
    at the start character of Patient.birthDate in the PropertyAccess define —
    asserts result is an ExpressionDef

Files Created

provider/FormattingProviderTest.java (new — was entirely untested)

  • Direct instantiation: new FormattingProvider(new TestContentService())
  • format_validCql_returnsOneEdit: formats Two.cql, asserts exactly one TextEdit
    returned, range starts at (0, 0), and newText is non-blank
  • format_syntaxError_throwsIllegalArgument: formats SyntaxError.cql, asserts
    IllegalArgumentException is thrown (formatter rejects CQL with parse errors)

resources/.../SyntaxError.cql (new fixture)
library SyntaxError version '1.0.0'

define "Broken":
    +++ not valid cql +++

Used by both DiagnosticsServiceTest.syntaxError_returnsDiagnostic and
FormattingProviderTest.format_syntaxError_throwsIllegalArgument.


Test Count

Before: 163 (includes 4 Spring-based tests that are now removed)
After: 165

Removed: 4 (LanguageServerTest: handshake, hoverInt, hoverNothing, hoverList)
Added: 6 (validCql_noErrors, syntaxError_returnsDiagnostic, hoverOnLibraryRef,
hoverOnDefineName, positionInExpressionRef_returnsExpressionDef,
positionAtExpressionBoundary_returnsExpressionDef)
Added: 2 (FormattingProviderTest: format_validCql_returnsOneEdit,
format_syntaxError_throwsIllegalArgument)

Net: +2


Verification

mvn test  # from cql-language-server/ — BUILD SUCCESS, 165 tests, 0 failures
grep -r SpringBootTest ls/server/src/test  # no matches

adds github action ci support
@raleigh-g-thompson raleigh-g-thompson self-assigned this Mar 11, 2026
@raleigh-g-thompson raleigh-g-thompson added the enhancement New feature or request label Mar 11, 2026
@github-actions
Copy link
Copy Markdown

Formatting check succeeded!

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 11, 2026

Coverage Report

Overall Project 60.47%

There is no coverage information present for the Files changed

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.21%. Comparing base (04c0405) to head (4a9cc73).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #113      +/-   ##
============================================
+ Coverage     50.29%   55.21%   +4.92%     
- Complexity      278      299      +21     
============================================
  Files            46       46              
  Lines          1543     1543              
  Branches        189      189              
============================================
+ Hits            776      852      +76     
+ Misses          703      618      -85     
- Partials         64       73       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@brynrhodes brynrhodes merged commit ce7ff9b into master Mar 11, 2026
12 checks passed
@brynrhodes brynrhodes deleted the feature/improve-unit-tests branch March 11, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update unit tests and add CI support

2 participants