0 Replies Latest reply on Dec 5, 2008 2:01 PM by slawek t

    How to write tests in groovy?

    slawek t Novice

      How to write integration tests in groovy not supporting inner classes?


      example code in groovy


      public class SomeActionTest extends SeamTest {
      
          @Test
          public void test_doSomething( ) throws Exception {
              new FacesRequest( ) {
                  @Override
                  protected void updateModelValues( ) throws Exception {
                      // set form input to model attributes
                      setValue( "#{someAction.value}", "seam" );
                  }
      
                  @Override
                  protected void invokeApplication( ) {
                      // call action methods here
                      invokeMethod( "#{someAction.doSomething()}" );
                  }
      
                  @Override
                  protected void renderResponse( ) {
                      // check model attributes if needed
                      assert getValue( "#{someAction.value}" ) == "seam";
                  }
              }.run( );
          }
      }
      



      gives compilation result


      BUILD FAILED
      D:\Users\st\eclipse-workspace\myproject\build.xml:347: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, D:\Users\st\eclipse-workspace\myproject\src\test\pl\myproject\test\SomeActionTest.groovy: 15: Unknown type: METHOD_DEF at line: 15 column: 28. File: D:\Users\st\eclipse-workspace\myproject\src\test\pl\myproject\test\SomeActionTest.groovy @ line 15, column 28.
                     protected void updateModelValues( ) throws Exception {
                                    ^
      1 error
      



      I've tried with groovy map and closures


      def m = [updateModelValues: {...}, invokeApplication: {...}, renderResponse: {...}] as FacesRequest;
      m.run( );



      and it wasn't work too.


      How to solve this problem in convenient way?