Sha256: 29b79163270e0c701f2819df3d91a4995075c87bd3891e34b554dfcb1b17f07b

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

package asunit.framework {

    import p2.reflect.Reflection;
    import p2.reflect.ReflectionMethod;
	
	public class LegacyTestIterator extends TestIterator {
		
        public function LegacyTestIterator(test:Object, testMethodName:String = "") {
            super(test, testMethodName);
		} 

        override protected function getTestMethods(test:Object):Array {
            var annotatedMethods:Array = super.getTestMethods(test);
            var namedMethods:Array = getTestMethodsByName(test);
            return annotatedMethods.concat(namedMethods);
        }

        protected function getTestMethodsByName(instance:Object):Array {
            var methods:Array = [];
            var reflection:Reflection = Reflection.create(instance);
            reflection.methods.forEach(function(methodReflection:ReflectionMethod, index:int, list:Array):void {
                if(methodNameBeginsWithTest(methodReflection) && methodDoesNotHaveTestAnnotation(methodReflection)) {
                    methods.push( new Method(instance, methodReflection) );
                }
            });

            methods.sortOn('name');
            return methods;
        }

        protected function methodNameBeginsWithTest(method:ReflectionMethod):Boolean {
            return (method.name.match(/^test/) != null);
        }

        protected function methodDoesNotHaveTestAnnotation(method:ReflectionMethod):Boolean {
            return (method.getMetaDataByName('Test') == null);
        }
	}
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
asunit4-4.2.3.pre src/asunit/framework/LegacyTestIterator.as
asunit4-4.2.2.pre src/asunit/framework/LegacyTestIterator.as
asunit4-4.2.1.pre src/asunit/framework/LegacyTestIterator.as