· JUnitStaticSuite: The suite() method in a JUnit test needs to be both public and static.
翻譯 Junit靜態套件:在Junit測試中suite()方法需要是公用的和靜態
· JUnitSpelling: Some JUnit framework methods are easy to misspell.
翻譯 Junit拼字:一些Junit架構方法容易拼字錯誤。
· JUnitAssertionsShouldIncludeMessage: JUnit assertions should include a message - i.e., use the three argument version of assertEquals(), not the two argument version.
翻譯 Junit斷言應該包含提示資訊:Junit斷言應該包含提示資訊-比如你應該使用三個參數的assertEquals()方法,而不使用兩個參數的。
· JUnitTestsShouldIncludeAssert: JUnit tests should include at least one assertion. This makes the tests more robust, and using assert with messages provide the developer a clearer idea of what the test does.
翻譯 Junit測試應該包含斷言:Junit測試應該至少包含一個斷言。這能讓測試更健壯,而且使用附帶提示資訊的斷言能讓開發人員清楚的瞭解測試到底做了什麼。
· TestClassWithoutTestCases: Test classes end with the suffix Test. Having a non-test class with that name is not a good practice, since most people will assume it is a test case. Test classes have test methods named testXXX.
翻譯 測試類別沒有用例:測試類別以Test作為尾碼。非測試類別的命名含有test作為尾碼不是好的方式,因為大多數人會以為它是一個測試案例。測試類別中的測試方法命名方式是testXXX。
· UnnecessaryBooleanAssertion: A JUnit test assertion with a boolean literal is unnecessary since it always will eval to the same thing. Consider using flow control (in case of assertTrue(false) or similar) or simply removing statements like assertTrue(true) and assertFalse(false). If you just want a test to halt, use the fail method.
翻譯 不必要的布爾斷言:包含一個布爾字面量的測試斷言是不必要的,因為它總是計算同樣的值。如果考慮流程式控制制(一旦出現assertTrue(false)或類似字眼)或僅僅移除類似assertTrue(true)和assertFalse(false)等運算式。如果你只是打算測試掛起,可以使用fail方法。
· UseAssertEqualsInsteadOfAssertTrue: This rule detects JUnit assertions in object equality. These assertions should be made by more specific methods, like assertEquals.
翻譯 使用assertEquals替代assertTrue:本規則檢查Junit斷言在對象值上的相等性。這些斷言應該由更多特定的方法組成,例如assertEquals。
· UseAssertSameInsteadOfAssertTrue: This rule detects JUnit assertions in object references equality. These assertions should be made by more specific methods, like assertSame, assertNotSame.
翻譯 使用assertSame替代assertTrue:本規則檢查Junit斷言在對象引用上的相等性。此類斷言應該由更多特定方法組成,比如:assertSame,assertNotSame
· UseAssertNullInsteadOfAssertTrue: This rule detects JUnit assertions in object references equality. These assertions should be made by more specific methods, like assertNull, assertNotNull.
翻譯 使用assertNull替代assertTrue:本規則檢查Junit斷言對象引用的相等性,此類斷言應該由更多特定方法組成,比如:assertNull,assertNotNull
· SimplifyBooleanAssertion: Avoid negation in an assertTrue or assertFalse test. For example, rephrase: assertTrue(!expr); as: assertFalse(expr);
翻譯 簡化布爾斷言:避免在assertTrue或assertFalse方法測試時使用反向表達,比如:將assertTrue(!expr)換成assertFalse(expr)來表達