public static TestSuiteMethod[] allTesters(IOpenClass openClass) { List<TestSuiteMethod> res = new ArrayList<TestSuiteMethod>(); for (IOpenMethod tester : openClass.getMethods()) { if (isTester(tester)) { res.add((TestSuiteMethod) tester); } if (tester instanceof OpenMethodDispatcher && isTester(((OpenMethodDispatcher) tester).getTargetMethod())) { res.add((TestSuiteMethod) ((OpenMethodDispatcher) tester).getTargetMethod()); } } TestSuiteMethod[] testSuiteMethods = new TestSuiteMethod[res.size()]; return res.toArray(testSuiteMethods); }
/** * If tester is an instance of {@link TestSuiteMethod} and tested method * object in tester is equal to tested we consider tester is test for tested * method. */ public static boolean isTestForMethod(IOpenMethod tester, IOpenMethod tested) { if (!(tester instanceof TestSuiteMethod)) { return false; } IOpenMethod toTest = ((TestSuiteMethod) tester).getTestedMethod(); if (toTest == tested) { return true; } if (toTest instanceof OpenMethodDispatcher) { if (((OpenMethodDispatcher) toTest).getCandidates().contains(tested)) { return true; } } if (tested instanceof MethodDelegator) { return isTestForMethod(tester, tested.getMethod()); } if (tested instanceof OpenMethodDispatcher) { return isTestForMethod(tester, ((OpenMethodDispatcher) tested).getTargetMethod()); } return false; }