Package groovy.util

Examples of groovy.util.GroovyTestSuite


        try{
            GroovyClassLoader gcl = new GroovyClassLoader(TestUtil.class.getClassLoader());

            Class testClass = gcl.parseClass(script, "__GenRESTTestCase__");

            TestSuite suite = new GroovyTestSuite();

            final RoRequestBean roRequest = new RoRequestBean(request);
            final RoResponseBean roResponse = new RoResponseBean(response);

            Method[] m_arr = testClass.getDeclaredMethods();
            for(int i=0; i<m_arr.length; i++){
                /*
                Test for following:
                 * 1. Modifier should be public
                 * 2. Method should not be abstract
                 * 3. Return type should be void
                 * 4. Method name should start with `test'
                 * 5. Method should not expect any parameter
                 */
                int modifiers = m_arr[i].getModifiers();
                Class retType = m_arr[i].getReturnType();
                String methName = m_arr[i].getName();
                Class[] p_arr = m_arr[i].getParameterTypes();
                if(!Modifier.isPublic(modifiers) ||
                        Modifier.isAbstract(modifiers) ||
                        !retType.equals(Void.TYPE) ||
                        !methName.startsWith("test") ||
                        p_arr.length != 0){
                    continue;
                }
                RESTTestCase test = (RESTTestCase)GroovyTestSuite.createTest(testClass, methName);
                test.setRoRequestBean(roRequest);
                test.setRoResponseBean(roResponse);
                suite.addTest(test);
            }
            return suite;
        }
        catch(CompilationFailedException ex){
            throw new TestException("", ex);
View Full Code Here


                gcl.addClasspath(dependency.getAbsolutePath());
            }

            Class testClass = gcl.parseClass(script, "__GenRESTTestCase__");

            TestSuite suite = new GroovyTestSuite();

            Method[] m_arr = testClass.getDeclaredMethods();
            for(int i=0; i<m_arr.length; i++){
                /*
                Test for following:
                 * 1. Modifier should be public
                 * 2. Method should not be abstract
                 * 3. Return type should be void
                 * 4. Method name should start with `test'
                 * 5. Method should not expect any parameter
                 */
                int modifiers = m_arr[i].getModifiers();
                Class retType = m_arr[i].getReturnType();
                String methName = m_arr[i].getName();
                Class[] p_arr = m_arr[i].getParameterTypes();
                if(!Modifier.isPublic(modifiers) ||
                        Modifier.isAbstract(modifiers) ||
                        !retType.equals(Void.TYPE) ||
                        !methName.startsWith("test") ||
                        p_arr.length != 0){
                    continue;
                }
                RESTTestCase test = (RESTTestCase)GroovyTestSuite.createTest(testClass, methName);
                test.setRequest(request);
                test.setResponse(response);
                suite.addTest(test);
            }
            return suite;
        }
        catch(CompilationFailedException ex){
            throw new TestException("", ex);
View Full Code Here

TOP

Related Classes of groovy.util.GroovyTestSuite

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.