/** * If this result's related instance implements ITest or use @Test(testName=...), returns its test name, * otherwise returns null. */ @Override public String getTestName() { if (m_instance instanceof ITest) { return ((ITest) m_instance).getTestName(); } if (m_testClass.getTestName() != null) { return m_testClass.getTestName(); } return null; }
private void initTestClassesAndInstances() { // // TestClasses and instances // Object[] instances = getInstances(false); for (Object instance : instances) { if (instance instanceof ITest) { testName = ((ITest) instance).getTestName(); break; } } if (testName == null) { testName = iClass.getTestName(); } }
} else { if (m_instance instanceof ITest) { m_name = ((ITest) m_instance).getTestName(); } else if (testClass.getTestName() != null) { m_name = testClass.getTestName();
private void initTestClassesAndInstances() { // // TestClasses and instances // Object[] instances = getInstances(true, this.m_errorMsgPrefix); for (Object instance : instances) { instance = IParameterInfo.embeddedInstance(instance); if (instance instanceof ITest) { testName = ((ITest) instance).getTestName(); break; } } if (testName == null) { testName = iClass.getTestName(); } }
public ClassImpl(ITestContext context, Class<?> cls, XmlClass xmlClass, Object instance, Map<Class<?>, IClass> classes, IAnnotationFinder annotationFinder, ITestObjectFactory objectFactory) { m_testContext = context; m_class = cls; m_classes = classes; m_xmlClass = xmlClass; m_annotationFinder = annotationFinder; m_instance = instance; m_objectFactory = objectFactory; if (instance instanceof ITest) { m_testName = ((ITest) instance).getTestName(); } if (m_testName == null) { ITestAnnotation annotation = m_annotationFinder.findAnnotation(cls, ITestAnnotation.class); if (annotation != null && !annotation.getTestName().isEmpty()) { m_testName = annotation.getTestName(); } } m_hasParentModule = isStringNotEmpty(m_testContext.getSuite().getParentModule()); }
m_name = ((ITest) instance).getTestName(); if (m_name != null) { return;
/** * If this result's related instance implements ITest or use @Test(testName=...), returns its test * name, otherwise returns null. */ @Override public String getTestName() { if (this.m_method == null) { return null; } Object instance = this.m_method.getInstance(); if (instance instanceof ITest) { return ((ITest) instance).getTestName(); } if (m_method.getTestClass().getTestName() != null) { return m_method.getTestClass().getTestName(); } return null; }
public ClassImpl( ITestContext context, Class<?> cls, XmlClass xmlClass, Object instance, Map<Class<?>, IClass> classes, IAnnotationFinder annotationFinder, ITestObjectFactory objectFactory) { m_testContext = context; m_class = cls; m_classes = classes; m_xmlClass = xmlClass; m_annotationFinder = annotationFinder; m_instance = instance; m_objectFactory = objectFactory; if (instance instanceof ITest) { m_testName = ((ITest) instance).getTestName(); } if (m_testName == null) { ITestAnnotation annotation = m_annotationFinder.findAnnotation(cls, ITestAnnotation.class); if (annotation != null && !annotation.getTestName().isEmpty()) { m_testName = annotation.getTestName(); } } m_hasParentModule = isStringNotEmpty(m_testContext.getSuite().getParentModule()); }
@Test(description = GITHUB_1456) public void testCreateInstance1WithOneArgStringParamForConstructor() { Class<?> declaringClass = TestClassSample.class; Map<Class<?>, IClass> classes = Maps.newHashMap(); XmlTest xmlTest = new XmlTest(new XmlSuite()); xmlTest.setName(GITHUB_1456); IAnnotationFinder finder = new JDK15AnnotationFinder(new DefaultAnnotationTransformer()); IObjectFactory objectFactory = new ObjectFactoryImpl(); Object object = InstanceCreator.createInstanceUsingObjectFactory(declaringClass, classes, xmlTest, finder, objectFactory, false,""); Assert.assertTrue(object instanceof ITest); Assert.assertEquals(((ITest) object).getTestName(), GITHUB_1456); } }