-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathTestCaseNoTests.qhelp
More file actions
53 lines (38 loc) · 1.43 KB
/
TestCaseNoTests.qhelp
File metadata and controls
53 lines (38 loc) · 1.43 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>
A JUnit 3.8 test case class (that is, a non-abstract class that is a subtype of <code>junit.framework.TestCase</code>)
should contain test methods, and each method must have the correct signature to be used by JUnit.
Otherwise, the JUnit test runner will fail with an error message.
</p>
</overview>
<recommendation>
<p>
Ensure that the test case class contains some test methods, and that each method is of the form:
</p>
<pre>
public void testXXX() {
// ...
}
</pre>
<p>Note that the method name must start with <code>test</code> and the method must not take any
parameters.</p>
<p>If the test case class is intended strictly for subclassing by other test case classes, consider
making it abstract to document this intention. It will then no longer be flagged by this query.</p>
<p>This rule applies only to JUnit 3.8-style test case classes. In JUnit 4, it is no longer required
to extend <code>junit.framework.TestCase</code> to mark test methods.</p>
</recommendation>
<example>
<p>In the following example, <code>TestCaseNoTests38</code> does not contain any valid JUnit test
methods. However, <code>MyTests</code> contains two valid JUnit test methods.</p>
<sample src="TestCaseNoTests.java" />
</example>
<references>
<li>
JUnit: <a href="http://junit.sourceforge.net/junit3.8.1/doc/cookbook/cookbook.htm">JUnit Cookbook</a>.
</li>
</references>
</qhelp>