-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathTestCaseNoTests.ql
More file actions
33 lines (30 loc) · 932 Bytes
/
TestCaseNoTests.ql
File metadata and controls
33 lines (30 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* @name Test case has no tests
* @description A test case class whose test methods are not recognized by JUnit 3.8 as valid
* declarations is not used.
* @kind problem
* @problem.severity recommendation
* @precision low
* @id java/test-case-without-tests
* @tags testability
* maintainability
* frameworks/junit
*/
import java
// `suite()` methods in `TestCase`s also count as test methods.
class SuiteMethod extends Method {
SuiteMethod() {
this.getDeclaringType() instanceof JUnit38TestClass and
this.isPublic() and
this.isStatic() and
this.hasNoParameters()
}
}
from JUnit38TestClass j
where
j.fromSource() and
not j.getAnAnnotation().getType().hasQualifiedName("org.junit", "Ignore") and
not j.isAbstract() and
not exists(TestMethod t | t.getDeclaringType() = j) and
not exists(SuiteMethod s | s.getDeclaringType() = j)
select j, "TestCase has no tests."