All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mockit.internal.util.TestMethod Maven / Gradle / Ivy

Go to download

JMockit is a Java toolkit for automated developer testing. It contains mocking/faking APIs and a code coverage tool, supporting both JUnit and TestNG. The mocking APIs allow all kinds of Java code, without testability restrictions, to be tested in isolation from selected dependencies.

There is a newer version: 1.49
Show newest version
/*
 * Copyright (c) 2006 Rogério Liesenfeld
 * This file is subject to the terms of the MIT license (see LICENSE.txt).
 */
package mockit.internal.util;

import java.lang.annotation.*;
import java.lang.reflect.*;
import javax.annotation.*;

public final class TestMethod
{
   @Nonnull public final String testClassDesc;
   @Nonnull public final String testMethodDesc;
   @Nonnull private final Type[] parameterTypes;
   @Nonnull private final Class[] parameterClasses;
   @Nonnull private final Annotation[][] parameterAnnotations;
   @Nonnull private final Object[] parameterValues;

   public TestMethod(@Nonnull Method testMethod, @Nonnull Object[] parameterValues)
   {
      testClassDesc = mockit.external.asm.Type.getInternalName(testMethod.getDeclaringClass());
      testMethodDesc = testMethod.getName() + mockit.external.asm.Type.getMethodDescriptor(testMethod);
      parameterTypes = testMethod.getGenericParameterTypes();
      parameterClasses = testMethod.getParameterTypes();
      parameterAnnotations = testMethod.getParameterAnnotations();
      this.parameterValues = parameterValues;
   }

   @Nonnegative public int getParameterCount() { return parameterTypes.length; }
   @Nonnull public Type getParameterType(@Nonnegative int index) { return parameterTypes[index]; }
   @Nonnull public Class getParameterClass(@Nonnegative int index) { return parameterClasses[index]; }
   @Nonnull public Annotation[] getParameterAnnotations(@Nonnegative int index) { return parameterAnnotations[index]; }
   @Nullable public Object getParameterValue(@Nonnegative int index) { return parameterValues[index]; }
   public void setParameterValue(@Nonnegative int index, @Nullable Object value) { parameterValues[index] = value; }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy