Its also done for GroovyStep, see GroovyInvoker:

                try
                {
                        LOG.debug("Evaluating script: " + 
StringUtils.abbreviate(script, 20));
            shell.evaluate(script);
                }
                catch (final CompilationFailedException e)
                {
                        LOG.error("CompilationFailedException", e);
                        throw new StepExecutionException("Cannot compile groovy 
code: " + script,
step, e);
                }
        catch (final AssertionError e) {
            LOG.info("AssertionError", e);
            throw new StepFailedException("Assertion failed within groovy
code: " + script, step);
        }

It must be some special thing about MacroDef...

cheers
Mittie

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Paul King
> Sent: Mittwoch, 5. Juli 2006 14:28
> To: [EMAIL PROTECTED]
> Subject: Re: [Webtest] groovy asserts in macrodefs
>
>
>
> Hi Sergey, can you put in a feature request.
> The following is from the scriptStep selftest:
>
>             <steps>
>                 <scriptStep description="passing assertion"
> language="groovy">
>                     someText = "this is some text"
>                     someRegex = /some text/
>                     assert someText =~ someRegex
>                 </scriptStep>
>                 <not description="expected to fail">
>                     <scriptStep description="failing assertion"
> language="groovy">
>                         someText = "this is some text"
>                         someRegex = /other text/
>                         assert someText =~ someRegex
>                     </scriptStep>
>                 </not>
>             </steps>
>
> and shows this works for scriptStep. We will need to replicate the
> exception handling logic for the groovy step too. You can use
> scriptStep in the meantime.
>
> Cheers, Paul.
>
> Sergey Batishchev wrote:
> > Hi,
> > we recently started WebTest canoo (R_1353) and discovered one unusual
> > piece of behavior.
> >
> > When you do groovy "asserts" from macrodefs, they cause test error, not
> > failure. This makes report not very readable and stops you from doing
> > "<not>" when you want to build your own groovy steps...
> >
> > As I am really new to this, can you explain if this is an issue or we
> > just need to "fail" steps in a different way here from within
> the groovy?
> >
> > For example, the following passes just fine:
> > ...<not><groovy>System.out.println("Test1");assert
> 1==3;</groovy></not>...
> >
> > While the following fails with exception:
> >            <macrodef name="sampleMacro">
> >                        <sequential>
> >                                    <groovy>
> >
> > System.out.println("Test2");assert 1==3;
> >                                    </groovy>
> >                        </sequential>
> >            </macrodef>
> > ...
> > <not><groovy>System.out.println("Test1");assert 1==3;</groovy></not>
> > ...
> >
> > Thanks in advance! Sergey.
> >
> > PS: Actual exception is below:
> > com.canoo.webtest.engine.StepExecutionException: Unexpected exception
> > caught: C:\Canoo WebTest\tests\FGI Load Tracking\build.xml:26: The
> > following error occurred while executing this line:
> > C:\Canoo WebTest\tests\FGI Load Tracking\build.xml:18:
> > com.canoo.webtest.engine.StepFailedException: Assertion failed within
> > groovy code:
> >    System.out.println("Test2");assert 1==3;
> >   , Step: GroovyStep at C:\Canoo WebTest\tests\FGI Load
> > Tracking\build.xml:18:  with (taskName="groovy"), Step: AntWrapper at
> > with ()
> > at com.canoo.webtest.steps.Step.handleUnexpectedException(Step.java:457)
> > at com.canoo.webtest.steps.Step.execute(Step.java:133)
> > at org.apache.tools.ant.Task.perform(Task.java:364)
> > at com.canoo.webtest.steps.StepUtil.performStanza(StepUtil.java:34)
> > at
> >
> com.canoo.webtest.steps.AbstractStepContainer.executeContainedStep
> (AbstractStepContainer.java:150)
> >
> > at com.canoo.webtest.steps.control.NotStep.doExecute(NotStep.java:46)
> > at com.canoo.webtest.steps.Step.execute(Step.java:130)
> > at org.apache.tools.ant.Task.perform(Task.java:364)
> > at
> >
> com.canoo.webtest.ant.TestStepSequence.executeSteps(TestStepSequen
> ce.java:58)
> >
> > at
> >
> com.canoo.webtest.ant.TestStepSequence.doExecute(TestStepSequence.java:39)
> > at com.canoo.webtest.steps.Step.execute(Step.java:130)
> > at org.apache.tools.ant.Task.perform(Task.java:364)
> > at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:152)
> > at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
> > at org.apache.tools.ant.Task.perform(Task.java:364)
> > at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:64)
> > at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
> > at org.apache.tools.ant.Task.perform(Task.java:364)
> > at
> >
> org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.
> java:378)
> > at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
> > at org.apache.tools.ant.Task.perform(Task.java:364)
> > at org.apache.tools.ant.Target.execute(Target.java:341)
> > at org.apache.tools.ant.Target.performTasks(Target.java:369)
> > at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
> > at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
> > at
> >
> org.apache.tools.ant.helper.DefaultExecutor.executeTargets(Default
> Executor.java:40)
> >
> > at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
> > at org.apache.tools.ant.Main.runBuild(Main.java:668)
> > at org.apache.tools.ant.Main.startAnt(Main.java:187)
> > at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
> > at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
> > Caused by: C:\Canoo WebTest\tests\FGI Load Tracking\build.xml:26: The
> > following error occurred while executing this line:
> > C:\Canoo WebTest\tests\FGI Load Tracking\build.xml:18:
> > com.canoo.webtest.engine.StepFailedException: Assertion failed within
> > groovy code:
> >    System.out.println("Test2");assert 1==3;
> >   , Step: GroovyStep at C:\Canoo WebTest\tests\FGI Load
> > Tracking\build.xml:18:  with (taskName="groovy")
> > at
> >
> org.apache.tools.ant.ProjectHelper.addLocationToBuildException(Pro
> jectHelper.java:539)
> >
> > at
> >
> org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.
> java:380)
> > at org.apache.tools.ant.Task.perform(Task.java:364)
> > at com.canoo.webtest.extension.AntWrapper.doExecute(AntWrapper.java:85)
> > at com.canoo.webtest.steps.Step.execute(Step.java:130)
> > ... 29 more
> > Caused by: C:\Canoo WebTest\tests\FGI Load Tracking\build.xml:18:
> > com.canoo.webtest.engine.StepFailedException: Assertion failed within
> > groovy code:
> >    System.out.println("Test2");assert 1==3;
> >   , Step: GroovyStep at C:\Canoo WebTest\tests\FGI Load
> > Tracking\build.xml:18:  with (taskName="groovy")
> > at org.apache.tools.ant.Task.perform(Task.java:373)
> > at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:64)
> > at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
> > at org.apache.tools.ant.Task.perform(Task.java:364)
> > at
> >
> org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.
> java:378)
> > ... 32 more
> > Caused by: com.canoo.webtest.engine.StepFailedException: Assertion
> > failed within groovy code:
> >    System.out.println("Test2");assert 1==3;
> >   , Step: GroovyStep at C:\Canoo WebTest\tests\FGI Load
> > Tracking\build.xml:18:  with (taskName="groovy")
> > at
> >
> com.canoo.webtest.extension.groovy.GroovyInvoker.doExecute(GroovyI
> nvoker.java:49)
> >
> > at
> >
> com.canoo.webtest.extension.groovy.GroovyStep.doExecute(GroovyStep
> .java:27)
> > at com.canoo.webtest.steps.Step.execute(Step.java:130)
> > at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
> > at org.apache.tools.ant.Task.perform(Task.java:364)
> > ... 36 more
> >
> >
> > _______________________________________________
> > WebTest mailing list
> > [email protected]
> > http://lists.canoo.com/mailman/listinfo/webtest
> >
> >
>
> _______________________________________________
> WebTest mailing list
> [email protected]
> http://lists.canoo.com/mailman/listinfo/webtest

_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to