/** * @deprecated Unused */ @Deprecated public static String[] groupsForThisMethodForConfiguration(Method m, IAnnotationFinder finder) { String[] result = {}; // Collect groups on the method ITestAnnotation tm = AnnotationHelper.findTest(finder, m); if (null != tm) { result = tm.getGroups(); } return result; }
private static boolean shouldCreateBeforeAfterGroup(String[] groups, IAnnotationFinder finder, Class<?> clazz, boolean isInheritGroups) { if (!isInheritGroups) { return groups.length > 0; } ITestAnnotation test = AnnotationHelper.findTest(finder, clazz); if (test == null) { return groups.length > 0; } return groups.length > 0 || test.getGroups().length > 0; }
/** * @deprecated Unused */ @Deprecated public static String[] groupsForThisMethodForTest(Method m, IAnnotationFinder finder) { List<String> vResult = Lists.newArrayList(); Class<?> cls = m.getDeclaringClass(); // Collect groups on the class ITestAnnotation tc = AnnotationHelper.findTest(finder, cls); if (null != tc) { for (String group : tc.getGroups()) { vResult.add(group); } } // Collect groups on the method ITestAnnotation tm = AnnotationHelper.findTest(finder, m); if (null != tm) { String[] groups = tm.getGroups(); for (String group : groups) { vResult.add(group); } } return vResult.toArray(new String[vResult.size()]); }
@Test public void verifyTestGroupsInheritance() throws SecurityException, NoSuchMethodException { Map<String, List<String>> dataset = new HashMap<>(); dataset.put("groups1", Arrays.asList("method-test3", "child-class-test3", "base-class")); dataset.put("groups2", Arrays.asList("child-class-test3", "base-class")); for (Map.Entry<String, List<String>> data : dataset.entrySet()) { Method method = MTest3.class.getMethod(data.getKey()); ITestAnnotation test1 = m_finder.findAnnotation(method, ITestAnnotation.class); List<String> expected = data.getValue(); Assert.assertEqualsNoOrder(expected.toArray(new String[expected.size()]), test1.getGroups()); } }
public void verifyTestMethodLevel() throws SecurityException, NoSuchMethodException { // // Tests on MTest1SampleTest // Method method = MTest1.class.getMethod("f"); ITestAnnotation test1 = m_finder.findAnnotation(method, ITestAnnotation.class); Assert.assertTrue(test1.getEnabled()); Assert.assertEqualsNoOrder(test1.getGroups(), new String[] { "group1", "group3", "group4", "group2" }); Assert.assertTrue(test1.getAlwaysRun()); Assert.assertEqualsNoOrder(test1.getDependsOnGroups(), new String[] { "dg1", "dg2", "dg3", "dg4" }); Assert.assertEqualsNoOrder(test1.getDependsOnMethods(), new String[] { "dm1", "dm2", "dm3", "dm4" }); Assert.assertEquals(test1.getTimeOut(), 142); Assert.assertEquals(test1.getInvocationCount(), 143); Assert.assertEquals(test1.getSuccessPercentage(), 61); Assert.assertEquals(test1.getDataProvider(), "dp2"); Assert.assertEquals(test1.getDescription(), "Method description"); Class[] exceptions = test1.getExpectedExceptions(); Assert.assertEquals(exceptions.length, 1); Assert.assertEquals(exceptions[0], NullPointerException.class); }
public void verifyTestClassLevel() { // // Tests on MTest1SampleTest // ITestAnnotation test1 = m_finder.findAnnotation(MTest1.class, ITestAnnotation.class); Assert.assertTrue(test1.getEnabled()); Assert.assertEquals(test1.getGroups(), new String[] { "group1", "group2" }); Assert.assertTrue(test1.getAlwaysRun()); Assert.assertEqualsNoOrder(test1.getDependsOnGroups(), new String[] { "dg1", "dg2" }, "depends on groups"); Assert.assertEqualsNoOrder( test1.getDependsOnMethods(), new String[] { "dm1", "dm2" }); Assert.assertEquals(test1.getTimeOut(), 42); Assert.assertEquals(test1.getInvocationCount(), 43); Assert.assertEquals(test1.getSuccessPercentage(), 44); Assert.assertEquals(test1.getThreadPoolSize(), 3); Assert.assertEquals(test1.getDataProvider(), "dp"); Assert.assertEquals(test1.getDescription(), "Class level description"); // // Tests on MTest1SampleTest (test defaults) // ITestAnnotation test2 = m_finder.findAnnotation(MTest2.class, ITestAnnotation.class); // test default for enabled Assert.assertTrue(test2.getEnabled()); Assert.assertFalse(test2.getAlwaysRun()); Assert.assertEquals(test2.getTimeOut(), 0); Assert.assertEquals(test2.getInvocationCount(), 1); Assert.assertEquals(test2.getSuccessPercentage(), 100); Assert.assertEquals(test2.getDataProvider(), ""); }
ITestAnnotation classAnnotation = m_annotationFinder.findAnnotation(m_methodClass, ITestAnnotation.class); if (classAnnotation != null) { String[] groups = classAnnotation.getGroups(); Map<String, String> newGroups = Maps.newHashMap(); for (String g : getGroups()) {
m_annotationFinder.findAnnotation(m_methodClass, ITestAnnotation.class); if (classAnnotation != null) { String[] groups = classAnnotation.getGroups(); Map<String, String> newGroups = Maps.newHashMap(); for (String g : getGroups()) {