[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit HttpUnitSuite.java,1.19,1.20
Brought to you by:
russgold
From: Russell G. <rus...@us...> - 2002-08-01 20:23:20
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv4813/test/com/meterware/httpunit Modified Files: HttpUnitSuite.java Log Message: Added JavaScript support for text field values Index: HttpUnitSuite.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HttpUnitSuite.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- HttpUnitSuite.java 24 Jul 2002 17:32:08 -0000 1.19 +++ HttpUnitSuite.java 1 Aug 2002 20:23:16 -0000 1.20 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2001, Russell Gold +* Copyright (c) 2000-2002, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -19,11 +19,15 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ - import com.meterware.pseudoserver.PseudoServerTest; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.InvocationTargetException; + import junit.framework.Test; import junit.framework.TestSuite; +import junit.framework.TestCase; /** @@ -31,6 +35,9 @@ **/ public class HttpUnitSuite { + private static Class[] NO_PARAMETERS = new Class[ 0 ]; + + public static void main( String[] args ) { junit.textui.TestRunner.run( suite() ); } @@ -54,15 +61,27 @@ result.addTest( JTidyPrintWriterTest.suite() ); addOptionalTestCase( result, "com.meterware.httpunit.XMLPageTest" ); addOptionalTestCase( result, "com.meterware.httpunit.FileUploadTest" ); + addOptionalTestCase( result, "com.meterware.httpunit.javascript.ScriptingTest" ); + addOptionalTestCase( result, "com.meterware.servletunit.ServletUnitSuite" ); return result; } private static void addOptionalTestCase( TestSuite testSuite, String testCaseName ) { try { - testSuite.addTest( new TestSuite( Class.forName( testCaseName ) ) ); + final Class testClass = Class.forName( testCaseName ); + Method suiteMethod = testClass.getMethod( "suite", NO_PARAMETERS ); + if (suiteMethod != null && Modifier.isStatic( suiteMethod.getModifiers() )) { + testSuite.addTest( (Test) suiteMethod.invoke( null, NO_PARAMETERS ) ); + } else if (TestCase.class.isAssignableFrom( testClass )) { + testSuite.addTest( new TestSuite( testClass ) ); + } else { + System.out.println( "Note: test suite " + testCaseName + " not a TestClass and has no suite() method" ); + } } catch (ClassNotFoundException e) { System.out.println( "Note: test suite " + testCaseName + " not found; skipping." ); + } catch (Exception e) { + System.out.println( "Note: unable to add " + testCaseName + ": " + e ); } } |