Package org.testng

Examples of org.testng.IMethodInstance


public class VerifyMethodInterceptor implements IMethodInterceptor {
  @Override
  public List<IMethodInstance> intercept(List<IMethodInstance> methods,
      ITestContext context) {
    List<IMethodInstance> result = Lists.newArrayList();
    IMethodInstance verifier = null;

    // Doing a naive approach here: we run through the list of methods
    // twice, once to find the verifier and once more to actually create
    // the result. Obviously, this can be done with just one loop
    for (IMethodInstance m : methods) {
View Full Code Here


    List<IMethodInstance> result = new ArrayList<IMethodInstance>();
    for (final Method m : realClass.getDeclaredMethods()) {
      Annotation a = m.getAnnotation(Verify.class);
      if (a != null) {
        final ITestNGMethod vm = TestNGUtils.createITestNGMethod(tm, m);
        result.add(new IMethodInstance() {

          @Override
          public Object[] getInstances() {
            return tm.getInstances();
          }
View Full Code Here

    }


    private IMethodInstance mockIMethodAnnotatedWith(Class methodClass, boolean firstTestAnnotation,
                                                     boolean lastTestAnnotation, boolean orderAnnotation) throws Exception {
        IMethodInstance methodInstance = mock(IMethodInstance.class);
        ITestNGMethod testNgMethod = mock(ITestNGMethod.class);

        when(methodInstance.getMethod()).thenReturn(testNgMethod);
        when(testNgMethod.getRealClass()).thenReturn(methodClass);

        String methodName;
        if (firstTestAnnotation && lastTestAnnotation && orderAnnotation == true) {
            methodName = ClassWithMethodsToTest.WITH_TEST_ORDER_ONE_AND_FIRST_AND_LAST_ANNOTATION;
View Full Code Here

    private IMethodInstance mockIMethodDependantUponOtherMethods() throws Exception {
        return mockIMethodDependantUponOtherMethods(ClassWithMethodsToTest.class);
    }

    private IMethodInstance mockIMethodDependantUponOtherMethods(Class methodClass) throws Exception {
        IMethodInstance methodInstance = mock(IMethodInstance.class);
        ITestNGMethod testNgMethod = mock(ITestNGMethod.class);

        when(methodInstance.getMethod()).thenReturn(testNgMethod);
        when(testNgMethod.getRealClass()).thenReturn(methodClass);
        when(testNgMethod.getMethodsDependedUpon()).thenReturn(new String[]{"method1, method2"});


        Method methodWithoutAnnotations = ClassWithMethodsToTest.class.getMethod(ClassWithMethodsToTest.WITHOUT_ANNOTATIONS);
View Full Code Here

        return methodInstance;
    }

    private IMethodInstance mockIMethodWithTestOrderAnnotationWithParamOne() throws Exception {

        IMethodInstance methodInstance = mock(IMethodInstance.class);
        ITestNGMethod testNgMethod = mock(ITestNGMethod.class);

        when(methodInstance.getMethod()).thenReturn(testNgMethod);
        when(testNgMethod.getRealClass()).thenReturn(ClassWithMethodsToTest.class);

        mockWithMethod(testNgMethod, ClassWithMethodsToTest.WITH_TEST_ORDER_ONE);

        when(testNgMethod.getMethodsDependedUpon()).thenReturn(new String[]{});
View Full Code Here

        return methodInstance;
    }

    private IMethodInstance mockIMethodWithTestOrderAnnotationWithParamTen() throws Exception {

        IMethodInstance methodInstance = mock(IMethodInstance.class);
        ITestNGMethod testNgMethod = mock(ITestNGMethod.class);

        when(methodInstance.getMethod()).thenReturn(testNgMethod);
        when(testNgMethod.getRealClass()).thenReturn(ClassWithMethodsToTest.class);

        mockWithMethod(testNgMethod, ClassWithMethodsToTest.WITH_TEST_ORDER_TEN);

        when(testNgMethod.getMethodsDependedUpon()).thenReturn(new String[]{});
View Full Code Here

TOP

Related Classes of org.testng.IMethodInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.