3 Replies Latest reply on Sep 27, 2007 12:08 PM by ssilvert

    Test own jsf component with JSFUnit

    mblondel

      I have written my own component which is a link.

      <exa:link id="myLink" value="next"/>


      in the html, I have something like this :
      <a id="myLink" onclick=...../>


      In my jsfUnit test, I would like to click this link a test it :
      client.clickCommandLink("myLink");


      I have try with changing the namingContainer

      client.clickCommandLink("myForm:myLink");


      But the result is always the same : jsfUnit tells me that the component with id "myLink" is not found.

      Can't my test our own component ?
      May be I didn't write my component correctly ?

        • 1. Re: Test own jsf component with JSFUnit
          ssilvert

          First, check the HTML source in your browser to see that you indeed rendered a component with an ID that ends in "myLink".

          Second, what kind of link does your custom component render? If it is a static link then you need to use client.click(). If it is a command link then you use client.commandLink().

          If the component relies on javascript to do a submit that is different from the usual commandLink submit then you will have to write a custom handler to test it with JSFUnit.

          Stan

          • 2. Re: Test own jsf component with JSFUnit
            mblondel

             

            First, check the HTML source in your browser to see that you indeed rendered a component with an ID that ends in "myLink".


            yes, it is

            If it is a static link then you need to use client.click().


            the method client.click() does not exist.

            Thanks for tour help

            • 3. Re: Test own jsf component with JSFUnit
              ssilvert

               

              "mblondel" wrote:

              If it is a static link then you need to use client.click().

              the method client.click() does not exist.


              My bad. Actually, I think both of these methods were renamed since I posted that.

              For static links, you want JSFClientSession.clickLink().

              For clicking a commandLink, you want JSFClientSession.clickCommandLink()

              Stan
              http://www.jsfunit.org