Junit
文章平均质量分 75
joyyq
这个作者很懒,什么都没留下…
展开
-
Use junit test private method
The class contain private method need to be test.public class TestPrivateMethod {private int add(int a, int b){return a+b;}}The junit for private method test.public class TestPri转载 2012-07-21 21:43:28 · 522 阅读 · 0 评论 -
Mocking private methods
Quick summaryUse the @RunWith(PowerMockRunner.class) annotation at the class-level of the test case.Use the @PrepareForTest(ClassWithPrivateMethod.class) annotation at the class-level of the tes转载 2012-07-21 21:48:05 · 585 阅读 · 0 评论 -
Partial mock local private method or public method in the class and suppress static initial block
public class Calc { static { System.out.println("hahaha"); } public int add(int a, int b) { return interADD(a, b); } private int interADD(int a, int b) { return a + b; } public int min原创 2013-03-06 11:49:21 · 1769 阅读 · 0 评论 -
Mock construction of new objects
Quick summaryUse the @RunWith(PowerMockRunner.class) annotation at the class-level of the test case.Use the @PrepareForTest(ClassThatCreatesTheNewInstance.class) annotation at the class-level of转载 2013-03-06 13:48:42 · 1512 阅读 · 0 评论