Package gw.test

Class TestClassHelper


  • public class TestClassHelper
    extends java.lang.Object
    Helper methods for analyzing methods, and instantiating test classes.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Map<java.lang.Class<?>,​java.util.List<org.objectweb.asm.tree.MethodNode>> cache  
    • Constructor Summary

      Constructors 
      Constructor Description
      TestClassHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends junit.framework.TestCase>
      junit.framework.Test
      createTestSuite​(java.lang.Class<T> clazz, java.lang.Iterable<java.lang.String> methodNames)  
      private static <T extends junit.framework.TestCase>
      java.lang.reflect.Constructor<T>
      getConstructor​(java.lang.Class<T> clazz)  
      private static int getLineNumber​(org.objectweb.asm.tree.MethodNode o2)  
      static <T extends junit.framework.TestCase>
      java.util.List<org.objectweb.asm.tree.MethodNode>
      getMethodsSorted​(java.lang.Class<T> clazz)
      Returns list of methods according to their order in the source file.
      private static org.objectweb.asm.tree.ClassNode parseClass​(java.lang.Class<?> clazz)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • cache

        private static final java.util.Map<java.lang.Class<?>,​java.util.List<org.objectweb.asm.tree.MethodNode>> cache
    • Constructor Detail

      • TestClassHelper

        public TestClassHelper()
    • Method Detail

      • getMethodsSorted

        public static <T extends junit.framework.TestCase> java.util.List<org.objectweb.asm.tree.MethodNode> getMethodsSorted​(java.lang.Class<T> clazz)
        Returns list of methods according to their order in the source file.

        Supertype methods go first in the list.

        Returns empty list if cannot find class file for the specified class. Class file is retrieved by using Class.getResourceAsStream(java.lang.String) so it won't work for classes generated at runtine.

        Parameters:
        clazz - class to analyze
        Returns:
        list of method names
      • getLineNumber

        private static int getLineNumber​(org.objectweb.asm.tree.MethodNode o2)
      • parseClass

        private static org.objectweb.asm.tree.ClassNode parseClass​(java.lang.Class<?> clazz)
      • createTestSuite

        public static <T extends junit.framework.TestCase> junit.framework.Test createTestSuite​(java.lang.Class<T> clazz,
                                                                                                java.lang.Iterable<java.lang.String> methodNames)
      • getConstructor

        private static <T extends junit.framework.TestCase> java.lang.reflect.Constructor<T> getConstructor​(java.lang.Class<T> clazz)