protected void initBeforeAfterGroups(Class<? extends ITestOrConfiguration> annotationClass, String[] groups) { String[] groupsAtMethodLevel = calculateGroupsTouseConsideringValuesAndGroupValues(annotationClass, groups); //@BeforeGroups and @AfterGroups annotation cannot be used at Class level. So its always null String[] groupsAtClassLevel = null; setGroups(getStringArray(groupsAtMethodLevel, groupsAtClassLevel)); initRestOfGroupDependencies(annotationClass); }
protected String getSignature() { if (m_signature == null) { m_signature = computeSignature(); } return m_signature; }
@Override public boolean hasMoreInvocation() { if (m_moreInvocationChecker != null) { try { return m_moreInvocationChecker.call(); } catch (Exception e) { // Should never append throw new RuntimeException(e); } } return getCurrentInvocationCount() < getInvocationCount() * getParameterInvocationCount(); }
@Override public String getQualifiedName() { return getRealClass().getName() + "." + getMethodName(); } }
ITestOrConfiguration annotation = getAnnotationFinder().findAnnotation(getConstructorOrMethod(), annotationClass); ITestOrConfiguration classAnnotation = getAnnotationFinder().findAnnotation(getConstructorOrMethod().getDeclaringClass(), annotationClass); Map<String, Set<String>> xgd = calculateXmlGroupDependencies(m_xmlTest); List<String> xmlGroupDependencies = Lists.newArrayList(); for (String g : getGroups()) { Set<String> gdu = xgd.get(g); if (gdu != null) { setGroupsDependedUpon( getStringArray(null != annotation ? annotation.getDependsOnGroups() : null, null != classAnnotation ? classAnnotation.getDependsOnGroups() : null), xmlGroupDependencies); getStringArray(null != annotation ? annotation.getDependsOnMethods() : null, null != classAnnotation ? classAnnotation.getDependsOnMethods() : null); setMethodsDependedUpon(methodsDependedUpon);
protected void initGroups(Class<? extends ITestOrConfiguration> annotationClass) { // // Init groups // { ITestOrConfiguration annotation = getAnnotationFinder().findAnnotation(getConstructorOrMethod(), annotationClass); ITestOrConfiguration classAnnotation = getAnnotationFinder().findAnnotation(getConstructorOrMethod().getDeclaringClass(), annotationClass); setGroups(getStringArray(null != annotation ? annotation.getGroups() : null, null != classAnnotation ? classAnnotation.getGroups() : null)); } // // Init groups depended upon // initRestOfGroupDependencies(annotationClass); }
private String computeSignature() { String classLong = m_method.getDeclaringClass().getName(); String cls = classLong.substring(classLong.lastIndexOf(".") + 1); StringBuilder result = stringify(cls, m_method); result .append("[pri:") .append(getPriority()) .append(", instance:") .append(getInstance()) .append(instanceParameters()) .append("]"); return result.toString(); }
private String[] calculateGroupsTouseConsideringValuesAndGroupValues(Class<? extends ITestOrConfiguration> annotationClass, String[] groups) { if (groups == null || groups.length == 0) { ITestOrConfiguration annotation = getAnnotationFinder().findAnnotation(getConstructorOrMethod(), annotationClass); groups = null != annotation ? annotation.getGroups() : null; } return groups; }
@Override public Map<String, String> findMethodParameters(XmlTest test) { // Get the test+suite parameters Map<String, String> result = test.getAllParameters(); for (XmlClass xmlClass: test.getXmlClasses()) { if (xmlClass.getName().equals(getTestClass().getName())) { result.putAll(xmlClass.getLocalParameters()); for (XmlInclude include : xmlClass.getIncludedMethods()) { if (include.getName().equals(getMethodName())) { result.putAll(include.getLocalParameters()); break; } } } } return result; }
/** * {@inheritDoc} Compares two BaseTestMethod using the test class then the associated * Java Method. */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } BaseTestMethod other = (BaseTestMethod) obj; boolean isEqual = m_testClass == null ? other.m_testClass == null : other.m_testClass != null && m_testClass.getRealClass().equals(other.m_testClass.getRealClass()) && m_instance == other.getInstance(); return isEqual && getConstructorOrMethod().equals(other.getConstructorOrMethod()); }
/** * {@inheritDoc} */ @Override public Object[] getInstances() { return new Object[] { getInstance() }; }
private IRetryAnalyzer getRetryAnalyzerConsideringMethodParameteters(ITestResult tr) { Object[] key = tr.getParameters(); IRetryAnalyzer retryAnalyzer = this.m_retryAnalyzer; if ((key != null && key.length != 0) && retryAnalyzer != null) { String keyAsString = getMethodName() + "_" + Arrays.toString(key); retryAnalyzer = m_testMethodToRetryAnalyzer.computeIfAbsent(keyAsString, o -> InstanceCreator.newInstance(this.m_retryAnalyzer.getClass())); } return retryAnalyzer; }
getAnnotationFinder().findAnnotation(getConstructorOrMethod(), annotationClass); ITestOrConfiguration classAnnotation = getAnnotationFinder() .findAnnotation(getConstructorOrMethod().getDeclaringClass(), annotationClass); Map<String, Set<String>> xgd = calculateXmlGroupDependencies(m_xmlTest); List<String> xmlGroupDependencies = Lists.newArrayList(); for (String g : getGroups()) { Set<String> gdu = xgd.get(g); if (gdu != null) { setGroupsDependedUpon( getStringArray( null != annotation ? annotation.getDependsOnGroups() : null, null != classAnnotation ? classAnnotation.getDependsOnGroups() : null), getStringArray( null != annotation ? annotation.getDependsOnMethods() : null, null != classAnnotation ? classAnnotation.getDependsOnMethods() : null); setMethodsDependedUpon(methodsDependedUpon);
protected void initGroups(Class<? extends ITestOrConfiguration> annotationClass) { ITestOrConfiguration annotation = getAnnotationFinder().findAnnotation(getConstructorOrMethod(), annotationClass); Object object = getInstance(); Class<?> clazz = getConstructorOrMethod().getDeclaringClass(); if (object != null) { clazz = object.getClass(); } ITestOrConfiguration classAnnotation = getAnnotationFinder().findAnnotation(clazz, annotationClass); setGroups( getStringArray( null != annotation ? annotation.getGroups() : null, null != classAnnotation ? classAnnotation.getGroups() : null)); initRestOfGroupDependencies(annotationClass); }
@Override public String getQualifiedName() { return getRealClass().getName() + "." + getMethodName(); }
private String[] calculateGroupsTouseConsideringValuesAndGroupValues( Class<? extends ITestOrConfiguration> annotationClass, String[] groups) { if (groups == null || groups.length == 0) { ITestOrConfiguration annotation = getAnnotationFinder().findAnnotation(getConstructorOrMethod(), annotationClass); groups = null != annotation ? annotation.getGroups() : null; } return groups; }
@Override public Map<String, String> findMethodParameters(XmlTest test) { // Get the test+suite parameters Map<String, String> result = test.getAllParameters(); for (XmlClass xmlClass : test.getXmlClasses()) { if (xmlClass.getName().equals(getTestClass().getName())) { result.putAll(xmlClass.getLocalParameters()); for (XmlInclude include : xmlClass.getIncludedMethods()) { if (include.getName().equals(getMethodName())) { result.putAll(include.getLocalParameters()); break; } } } } return result; }
/** * {@inheritDoc} Compares two BaseTestMethod using the test class then the associated Java Method. */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } BaseTestMethod other = (BaseTestMethod) obj; boolean isEqual = m_testClass == null ? other.m_testClass == null : other.m_testClass != null && m_testClass.getRealClass().equals(other.m_testClass.getRealClass()) && getInstance() == other.getInstance(); return isEqual && getConstructorOrMethod().equals(other.getConstructorOrMethod()); }
protected void initBeforeAfterGroups( Class<? extends ITestOrConfiguration> annotationClass, String[] groups) { String[] groupsAtMethodLevel = calculateGroupsTouseConsideringValuesAndGroupValues(annotationClass, groups); // @BeforeGroups and @AfterGroups annotation cannot be used at Class level. So its always null setGroups(getStringArray(groupsAtMethodLevel, null)); initRestOfGroupDependencies(annotationClass); }
@Override public boolean hasMoreInvocation() { if (m_moreInvocationChecker != null) { try { return m_moreInvocationChecker.call(); } catch (Exception e) { // Should never append throw new RuntimeException(e); } } return getCurrentInvocationCount() < getInvocationCount() * getParameterInvocationCount(); }