Class OrphanAssertionDetector
java.lang.Object
org.ek9lang.compiler.phase5.callgraph.OrphanAssertionDetector
Detects assertion statements that are not reachable from any @Test program.
E81011: Orphan assertion - assertion not reachable from any @Test
Assertions (assert, assertThrows, assertDoesNotThrow) are meant for testing. An assertion that isn't reachable from any @Test program will never execute as part of a test, creating false confidence that the code is tested.
Common causes:
- Forgot to write a @Test that calls the function with assertions
- Refactored tests and left assertions behind
- Helper function was removed from test call chain
-
Constructor Summary
ConstructorsConstructorDescriptionOrphanAssertionDetector(CallGraph callGraph, CallableErrorListenerLookup errorListenerLookup) Create a detector for orphan assertions. -
Method Summary
Modifier and TypeMethodDescriptionvoiddetect(Consumer<CallableInfo> consumer) Alternative API for just detection without error emission.Detect all orphan assertions and emit E81011 errors.Get the set of orphan assertion callables.
-
Constructor Details
-
OrphanAssertionDetector
public OrphanAssertionDetector(CallGraph callGraph, CallableErrorListenerLookup errorListenerLookup) Create a detector for orphan assertions.- Parameters:
callGraph- The call graph with assertion and reachability informationerrorListenerLookup- Function to get ErrorListener for emitting errors
-
-
Method Details
-
detectAndReport
-
detect
Alternative API for just detection without error emission. Useful for testing and analysis.- Parameters:
consumer- Callback for each orphan assertion callable found
-
getOrphanAssertions
-