UNPKG

pi-lens

Version:

Real-time code feedback for pi — LSP, linters, formatters, type-checking, structural analysis & booboo

62 lines (50 loc) • 1.2 kB
# Tests Include Assertions # Detects JUnit tests without assertions id: tests-include-assertions name: Tests Should Include Assertions severity: warning category: maintainability defect_class: correctness inline_tier: warning language: java message: "Test method should include at least one assertion" description: | Tests without assertions don't verify anything. They pass even if the code is broken. Use assertEquals, assertTrue, etc. ✅ FIX: Add meaningful assertions ```java @Test public void testAdd() { assertEquals(4, calculator.add(2, 2)); // GOOD } ``` query: | (method_declaration (modifiers (marker_annotation name: (identifier) @TEST)) name: (identifier) @NAME body: (block) @BODY (#match? @TEST "^(Test|ParameterizedTest|RepeatedTest)$")) metavars: - TEST - NAME - BODY post_filter: no_assertion_call tags: - maintainability - java - junit - testing examples: bad: | @Test public void testSomething() { calculator.add(2, 2); // BAD - no assertion } good: | @Test public void testSomething() { assertEquals(4, calculator.add(2, 2)); // GOOD } has_fix: false