• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

moosetechnology / MooseIDE / 19293949353

12 Nov 2025 10:15AM UTC coverage: 65.543% (-0.3%) from 65.828%
19293949353

push

github

web-flow
Merge pull request #1516 from moosetechnology/dead-code-java-rules

Dead code java rules

142 of 325 new or added lines in 10 files covered. (43.69%)

21293 of 32487 relevant lines covered (65.54%)

1.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.82
/src/MooseIDE-DeadCode/MiDeadCodeJavaTestAnnotationHeuristic.class.st
1
"
2
A heuristic to identify test methods based on their Java annotations
3

4
There are a number of annotations in Java that mark test methods (@Test, @Before, @BeforeEach,...)
5

6
Recognizes annotations from JUnit4 and JUnit5
7
"
8
Class {
9
        #name : 'MiDeadCodeJavaTestAnnotationHeuristic',
10
        #superclass : 'MiDeadCodeAbstractTestHeuristic',
11
        #category : 'MooseIDE-DeadCode-Rules',
12
        #package : 'MooseIDE-DeadCode',
13
        #tag : 'Rules'
14
}
15

16
{ #category : 'visiting' }
NEW
17
MiDeadCodeJavaTestAnnotationHeuristic >> accept: aTMethod [
×
NEW
18

×
NEW
19
        ^self notDead: aTMethod 
×
NEW
20
]
×
21

22
{ #category : 'accessing' }
23
MiDeadCodeJavaTestAnnotationHeuristic >> description [ 
2 ✔
24

2 ✔
25
        ^super description ,
2 ✔
26
        'In Java, different annotations mark methods of test class
2 ✔
27
         (@Test, @Before, @BeforeEach,...)'
2 ✔
28
]
2 ✔
29

30
{ #category : 'accessing' }
NEW
31
MiDeadCodeJavaTestAnnotationHeuristic >> isForEntryPoint [
×
NEW
32

×
NEW
33
        ^true
×
NEW
34
]
×
35

36
{ #category : 'testing' }
37
MiDeadCodeJavaTestAnnotationHeuristic >> junit4Annotations [
2 ✔
38
        "from https://www.softwaretestinghelp.com/junit-annotations-tutorial/"
2 ✔
39

2 ✔
40
        ^{ 'Test' . 'Before' . 'After' . 'BeforeClass' . 'AfterClass' }
2 ✔
41
]
2 ✔
42

43
{ #category : 'testing' }
44
MiDeadCodeJavaTestAnnotationHeuristic >> junit5Annotations [
2 ✔
45
        "from https://junit.org/junit5/docs/current/user-guide/
2 ✔
46
        other possibilities: DisplayName, DisplayNameGeneration, Nested, Tag, Disabled, AutoClose, TempDir, ExtendWith, RegisterExtension"
2 ✔
47

2 ✔
48
        ^{ 'Test' . 'ParameterizedTest' . 'RepeatedTest' . 'TestFactory' . 'TestTemplate' . 'TestClassOrder' . 'TestMethodOrder' . 'TestInstance' . 'BeforeEach' . 'AfterEach' . 'BeforeAll' . 'AfterAll' . 'Timeout' }
2 ✔
49

2 ✔
50
]
2 ✔
51

52
{ #category : 'accessing' }
53
MiDeadCodeJavaTestAnnotationHeuristic >> name [
2 ✔
54

2 ✔
55
        ^super name , 'Java @Test method'
2 ✔
56
]
2 ✔
57

58
{ #category : 'testing' }
59
MiDeadCodeJavaTestAnnotationHeuristic >> notDead: aTMethod [
2 ✔
60

2 ✔
61
        aTMethod annotationInstances ifEmpty: [ ^false ].
2 ✔
62

2 ✔
63
        (aTMethod annotationInstances anySatisfy: [ :annotation |
2 ✔
64
                self junit4Annotations includes: annotation annotationType name ])
2 ✔
65
                ifTrue: [ ^true ].
2 ✔
66

2 ✔
67
        (aTMethod annotationInstances anySatisfy: [ :annotation |
2 ✔
68
                self junit5Annotations includes: annotation annotationType name ]) 
2 ✔
69
                ifTrue: [ ^true ].
2 ✔
70

2 ✔
71
        ^false
2 ✔
72
]
2 ✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc