从FindBugs中学Java【三】

2. BX_BOXING_IMMEDIATELY_UNBOXEDhtml

double a = 100d;
double d = Double.valueOf(a);

Primitive value is boxed and then immediately unboxed.java

非必要的装箱并当即拆箱操做.框架

Intellij 也会给这样的提示:测试

没什么好说的ui


3. IJU_SETUP_NO_SUPERspa

好像是个遗留问题,出如今JUnit3的时代,e.g..net

JUnit3里会这么作code

public class TheTest extends TestCase {
// test methods ...
public static Test suite() {
return new TestSetup(new TestSuite(TheTest.class)) {
protected void setUp() throws Exception {
super.setUp();
// set-up code called only once
}
protected void tearDown() throws Exception {
// tear-down code called only once
super.tearDown();
}
};

因此须要这个super.setUp()来初始化
htm

JUnit4开始大规模使用Annotation,咱们有@Before @After来作这些事。blog

固然,如今JUnit4也已经用了不少年了,诸如Spock这样的测试框架也挺好用的~






Ref: 1  2 3

相关文章
相关标签/搜索