Menu

Ant Task with TestCaseListeners

Help
2007-03-07
2013-04-25
  • Jeremy Stowell

    Jeremy Stowell - 2007-03-07

    Christian,

    I am trying to run my scripts via an ant task, but I am getting an error on my test case listener.

    When I run the test through jameleon everything works as planned.  But when I try to run a particular script using an ant task I get the following error message.

    test.security:
         [echo] executing tests in scripts/security/**/*.xml with text @{contains}
    [jmln-test] java.lang.ClassNotFoundException: testcaseListeners.ResultsListenerT
    ag
    [jmln-test]     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    [jmln-test]     at java.security.AccessController.doPrivileged(Native Method)
    [jmln-test]     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    [jmln-test]     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    [jmln-test]     at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    [jmln-test]     at net.sf.jameleon.ExecuteTestCase.registerEventListeners(Execut
    eTestCase.java:104)
    [jmln-test]     at net.sf.jameleon.ant.ExecuteTestCaseTask.execute(ExecuteTestCa
    seTask.java:58)
    [jmln-test]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
    va:275)
    [jmln-test]     at org.apache.tools.ant.Task.perform(Task.java:364)
    [jmln-test]     at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.j
    ava:64)
    [jmln-test]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
    va:275)
    [jmln-test]     at org.apache.tools.ant.Task.perform(Task.java:364)
    [jmln-test]     at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInst
    ance.java:377)
    [jmln-test]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
    va:275)
    [jmln-test]     at org.apache.tools.ant.Task.perform(Task.java:364)
    [jmln-test]     at org.apache.tools.ant.Target.execute(Target.java:341)
    [jmln-test]     at org.apache.tools.ant.Target.performTasks(Target.java:369)
    [jmln-test]     at org.apache.tools.ant.Project.executeTarget(Project.java:1214)

    [jmln-test]     at org.apache.tools.ant.Project.executeTargets(Project.java:1062
    )
    [jmln-test]     at org.apache.tools.ant.Main.runBuild(Main.java:673)
    [jmln-test]     at org.apache.tools.ant.Main.startAnt(Main.java:188)
    [jmln-test]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
    [jmln-test]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
    [jmln-test] Could not register TestCaseListeners: testcaseListeners.ResultsListe
    nerTag
    [jmln-test]
    [jmln-test] Executing: C:\wrk\Jameleon-tests\scripts\security\External_Transfer_
    Disabled.xml

    Any ideas what could be causing this to happen?

    Thanks

     
    • Christian Hargraves

      Where's your TestCaseListener located (in src/java or in a separate jar file)?

       
    • Christian Hargraves

      I know this may be obvious, but that class is getting compiled before you run the Ant task right?

       
    • Jeremy Stowell

      Jeremy Stowell - 2007-03-07

      It is located in   src/testcaseListeners/ResultsListenerTag.java

      I have build the project before I try to run the ant task.

      The ant task kicks off the test but before the test runs it spits out that java error.

       
      • Christian Hargraves

        I will go home and try to reproduce the problem. In the meantime, I have another question. If you do the following steps, then you have a problem?

        1. Build
        2. Open GUI and run a script successfully w/o any errors in the console nor in the GUI.
        3. Run via Ant and you get the stack trace you pasted earlier.

        correct?

         
      • Christian Hargraves

        Okay, I was able to reproduce the problem with the ExecuteTestCaseTask, but not with the ExecuteTestCaseSeparateVMTask.

        The following is how I reproduced the problem:

        Download jameleon-test-suite-M4 and uzip it.

        Create a file in src/java/ex/ExTestCaseListner.java:

        package ex;

        import net.sf.jameleon.event.*;
        import net.sf.jameleon.*;

        public class ExTestCaseListener implements TestCaseListener{

                public void beginTestCase(TestCaseEvent event){
                        TestCaseTag tct = (TestCaseTag) event.getSource();
                        System.out.println("BEGIN: " +tct.getName());
                }

                public void endTestCase(TestCaseEvent event){
                        TestCaseTag tct = (TestCaseTag) event.getSource();
                        System.out.println("END: "+ tct.getName());
                }
        }

        Added the following line to jameleon.conf:

        TestCaseListeners=ex.ExTestCaseListener

        I then ran the following command lines w/o error:

        ./build.sh
        ./build.sh test.script -Dscript=**/httpunit-*.xml

        I then edited the build.xml's test.script target to call <run-test contains="" script="${script}"/> (instead of <run-test-vm contains="" script="${script}"/>)

        And I got the error, but the script continued executing. I will now look into trying to fix a for it.

         
    • Christian Hargraves

      Unfortunately, this required a fix against the source code. I applied the fix against SVN. If the separate vm task doesn't do the job for you, then you may want to check out the latest code and create your own jameleon-test-suite package.

       

Log in to post a comment.