Class TestSubjectInspector


  • public class TestSubjectInspector
    extends java.lang.Object
    Classifies test subject type. Date: 31/03/2017
    Author:
    Yaron Yamin
    • Constructor Detail

      • TestSubjectInspector

        public TestSubjectInspector​(boolean generateTestsForInheritedMethods)
    • Method Detail

      • hasTestableInstanceMethod

        public boolean hasTestableInstanceMethod​(java.util.List<Method> methods)
      • shouldBeTested

        public boolean shouldBeTested​(Method method)
        Returns:
        true - if method should is testable according to it's access modifiers and TestMe configuration
      • isMethodCalled

        public boolean isMethodCalled​(Method calledMethod,
                                      Method callerMethod)
        Parameters:
        calledMethod - a calledMethod, possible being called
        callerMethod - a calledMethod, possibly calling another
        Returns:
        true - if callerMethod implementation invokes calledMethod
      • formatSpockParamNamesTitle

        public java.lang.String formatSpockParamNamesTitle​(java.util.Map<java.lang.String,​java.lang.String> paramsMap,
                                                           boolean methodHasReturn)
        Parameters:
        paramsMap - test params for spock parameterized test
        methodHasReturn - true - if test method returns anything
        Returns:
        formatted string of spock test method name with tested parameters
      • formatSpockDataParameters

        public java.lang.String formatSpockDataParameters​(java.util.Map<java.lang.String,​java.lang.String> paramsMap,
                                                          java.lang.String linePrefix)
        Constructs a formatted string of parameterized params table for spock test. should probably be deprecated in the future, in favor of a method accepting paramsMap of Map<String,List<String>> for multiple values per input argument
        Parameters:
        paramsMap - map of test arguments. for constructing a single parameterized row.
        linePrefix - prefix add to resulting test params, typically used for indentation when passing the required preceding white spaces
        Returns:
        formatted string of parameterized params table for spock test.
      • isJavaFuture

        public boolean isJavaFuture​(Type type)
        Returns:
        true - if type is a Java future
      • isScalaFuture

        public boolean isScalaFuture​(Type type)
        Returns:
        true - if type is a Scala future
      • hasScalaFutureReturn

        public boolean hasScalaFutureReturn​(java.util.List<Method> methods)
        Returns:
        true - if any method has a Scala future type being returned
      • findOptimalConstructor

        @Nullable
        public @Nullable Method findOptimalConstructor​(Type type)
        find an optimal constructor in type declaration. a constructor that seems best suited to initialize the type.
        Parameters:
        type - a Type that has constructors
        Returns:
        the optimal constructor found
      • getJavaFutureTypes

        public java.util.Set<java.lang.String> getJavaFutureTypes()
        Returns:
        list of Java SDK types that represent a future. as fully qualified class names
      • getScalaFutureTypes

        public java.util.Set<java.lang.String> getScalaFutureTypes()
        Returns: