`
longgangbai
  • 浏览: 7256369 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

RestFuse的研究(一) HttpJunitRunner的实现

阅读更多

         在RestFuse是一种针对Rest WebService和Http的请求的单元测试的junit扩展的.既然是Junit的扩展肯定有相关的Runner对象,在RestFuse中主要为HttpJunitRunnner对象,继承自BlockJUnit4ClassRunner重写部分方法.因为RestFuse在测试单元方法中采用的时自己的注解HttpTest,所以需要重写获取单元测试方法computeTestMethods.

 

BlockJUnit4ClassRunner源代码方法如下:

 protected List<FrameworkMethod> computeTestMethods() {
  return getTestClass().getAnnotatedMethods(Test.class);
 }

 HttpJunitRunnner重写之后为:

	protected List<FrameworkMethod> computeTestMethods() {
		ArrayList result = new ArrayList();
		result.addAll(getTestClass().getAnnotatedMethods(HttpTest.class));
		List testAnnotatedMethods = getTestClass().getAnnotatedMethods(
				Test.class);
		for (FrameworkMethod method : testAnnotatedMethods) {
			if (!(result.contains(method))) {
				result.add(method);
			}
		}
		Collections.sort(result, new HttpOrderComparator());
		return result;
	}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics