Loading ...
Sorry, an error occurred while loading the content.

Are Import and DoFixture a Viable Duo?

Expand Messages
  • Dassing, Andrew
    Is there a way to employ an Import fixture in conjunction with a DoFixture? To illustrate, the following wiki is the intention, but will not work because the
    Message 1 of 6 , Aug 1, 2007
    • 0 Attachment
      Are Import and DoFixture a Viable Duo?

      Is there a way to employ an Import fixture in conjunction with a DoFixture?

      To illustrate, the following wiki is the intention, but will not work because the DoFixture must be the first table encountered on the page:

        !|Import|
        |com.bubba.gump.fit|

        !|My Session|
            :

      Any ideas or suggestions other than:

        !|com.bubba.gump.fit.MySessionFixture|
            :

      Many thanks,
      Andy

    • Tim Walker
      Can t you have a method in your DoFixture class that returns an Import Fixture? Never tried it but use it all the time with Row Fixtures... Tim
      Message 2 of 6 , Aug 1, 2007
      • 0 Attachment
        Can't you have a method in your DoFixture class that returns an Import Fixture? Never tried it but use it all the time with Row Fixtures...

        Tim

        On 8/1/07, Dassing, Andrew <andrew.dassing@...> wrote:

        Is there a way to employ an Import fixture in conjunction with a DoFixture?

        To illustrate, the following wiki is the intention, but will not work because the DoFixture must be the first table encountered on the page:

          !|Import|
          |com.bubba.gump.fit|

          !|My Session|
              :

        Any ideas or suggestions other than:

          !|com.bubba.gump.fit.MySessionFixture|
              :

        Many thanks,
        Andy


      • Rick Mugridge
        Hi Andy, The idea of an Import fixture is to avoid including the full class names in tables. The idea of DoFixture in flow is to avoid including any class
        Message 3 of 6 , Aug 1, 2007
        • 0 Attachment
          Hi Andy,

          The idea of an Import fixture is to avoid including the full class names in tables.

          The idea of DoFixture in flow is to avoid including any class names in tables after the first, plus much much more.

          I fail to see that your first choice below is any better than your second choice. What am I missing?

          Now, if you're not using DoFixture in flow, and want to write class names in all the tables, then starting with an Import makes good sense. However, I must admit to disliking such non-flow storytests, for several reasons. I don't want to expose extraneous implementation detail when I want to talk about business rules, and I want to avoid building such explicit dependencies.  I will give my other reasons if you want...

          Cheers, Rick

          Dassing, Andrew wrote:

          Is there a way to employ an Import fixture in conjunction with a DoFixture?

          To illustrate, the following wiki is the intention, but will not work because the DoFixture must be the first table encountered on the page:

            !|Import|
            |com.bubba.gump. fit|

            !|My Session|
                :

          Any ideas or suggestions other than:

            !|com.bubba. gump.fit. MySessionFixture |
                :

          Many thanks,
          Andy

        • Rick Mugridge
          Hi Tim, You could have your first DoFixture include code to have the same effect as the Import.table. Eg, in Java: public class MySession extends DoFixture {
          Message 4 of 6 , Aug 1, 2007
          • 0 Attachment
            Hi Tim,

            You could have your first DoFixture include code to have the same effect as the Import.table. Eg, in Java:

            public class MySession extends DoFixture {
                private App app = new App();

                public MySession() {
                  FixtureLoader.instance().addPackageToPath("com.bubba.gump. fit"); // BUT see below....
               }
            ....
            }

            I just copied and altered the FixtureLoader code from ImportFixture.java.

            While you can do this, I fail to see what you gain -- and you may be missing out on some opportunities (see below). Consider the two options:

            (1)

            !|MySession|

            |SessionRowFixture|
            |name|
            ...

            (2)

            !|MySession|

            |check sessions|
            |name|
            ...

            with an extra method in MySession:

              public RowFixture checkSessions() {
                 return new SessionRowFixture(someObjects);
              }

            The second option, which I much prefer, allows a meaningful name to be used (indirectly) to refer to the RowFixture. In addition, the checkSessions() method can pass some objects to the RowFixture, rather than having to use nasty global static variables to communicate between the fixtures.

            I'd actually go one step further. I'd write the checkSessions() method as follows:

            (3)

              public Set checkSessions() {        // or Set<Session> if you're using generics
                 return app.getSessions();
              }

            Because the action returns a Set, FitLibrary will automatically wrap it with a SetFixture to check the sessions. (Similar auto-wrapping occurs for arrays and Lists and etc.) So this means that you don't have to write a special subclass of RowFixture to handle sessions. So we've saved more code than we've had to write. (Note that the storytest tables don't need to be changed.)

            Within the storytests and the code, I aim to avoid unnecessary dependencies and unnecessary detail.

            Cheers, Rick
            www.rimuresearch.com
            www.zibreve.com

            Tim Walker wrote:

            Can't you have a method in your DoFixture class that returns an Import Fixture? Never tried it but use it all the time with Row Fixtures...

            Tim

            On 8/1/07, Dassing, Andrew <andrew.dassing@ nielsen.com> wrote:

            Is there a way to employ an Import fixture in conjunction with a DoFixture?

            To illustrate, the following wiki is the intention, but will not work because the DoFixture must be the first table encountered on the page:

              !|Import|
              |com.bubba.gump. fit|

              !|My Session|
                  :

            Any ideas or suggestions other than:

              !|com.bubba. gump.fit. MySessionFixture |
                  :

            Many thanks,
            Andy


          • Tim Walker
            Thank you very much for this clarification Rick. Best regards, Tim
            Message 5 of 6 , Aug 1, 2007
            • 0 Attachment
              Thank you very much for this clarification Rick.

              Best regards,

              Tim

              On 8/1/07, Rick Mugridge <rick@... > wrote:

              Hi Tim,

              You could have your first DoFixture include code to have the same effect as the Import.table. Eg, in Java:

              public class MySession extends DoFixture {
                  private App app = new App();

                  public MySession() {
                    FixtureLoader.instance().addPackageToPath("com.bubba.gump.fit"); // BUT see below....
                 }
              ....
              }

              I just copied and altered the FixtureLoader code from ImportFixture.java.

              While you can do this, I fail to see what you gain -- and you may be missing out on some opportunities (see below). Consider the two options:

              (1)

              !|MySession|

              |SessionRowFixture|
              |name|
              ...

              (2)

              !|MySession|

              |check sessions|
              |name|
              ...

              with an extra method in MySession:

                public RowFixture checkSessions() {
                   return new SessionRowFixture(someObjects);
                }

              The second option, which I much prefer, allows a meaningful name to be used (indirectly) to refer to the RowFixture. In addition, the checkSessions() method can pass some objects to the RowFixture, rather than having to use nasty global static variables to communicate between the fixtures.

              I'd actually go one step further. I'd write the checkSessions() method as follows:

              (3)

                public Set checkSessions() {        // or Set<Session> if you're using generics
                   return app.getSessions();
                }

              Because the action returns a Set, FitLibrary will automatically wrap it with a SetFixture to check the sessions. (Similar auto-wrapping occurs for arrays and Lists and etc.) So this means that you don't have to write a special subclass of RowFixture to handle sessions. So we've saved more code than we've had to write. (Note that the storytest tables don't need to be changed.)

              Within the storytests and the code, I aim to avoid unnecessary dependencies and unnecessary detail.

              Cheers, Rick
              www.rimuresearch.com
              www.zibreve.com

              Tim Walker wrote:

              Can't you have a method in your DoFixture class that returns an Import Fixture? Never tried it but use it all the time with Row Fixtures...

              Tim

              On 8/1/07, Dassing, Andrew <andrew.dassing@...> wrote:

              Is there a way to employ an Import fixture in conjunction with a DoFixture?

              To illustrate, the following wiki is the intention, but will not work because the DoFixture must be the first table encountered on the page:

                !|Import|
                |com.bubba.gump.fit|

                !|My Session|
                    :

              Any ideas or suggestions other than:

                !|com.bubba.gump.fit.MySessionFixture|
                    :

              Many thanks,
              Andy



            • Dassing, Andrew
              Your points are well taken, but the rub is that we re refactoring hundreds of pages of tests to migrate from FitNesse 2005 to the current. Our initial
              Message 6 of 6 , Aug 2, 2007
              • 0 Attachment
                Your points are well taken, but the rub is that we're refactoring hundreds of pages of tests to migrate from FitNesse 2005 to the current.  Our initial implementation had our custom fixtures rooted at fit for convenience which causes some trouble in DoTraverse/DoFixture land because fit- and fitnesse-rooted fixtures are deemed "system" fixtures with "system" methods.
                 
                In short, it would be far easier to prepend an |Import| to each page than muck about with fixture names in all their various references.
                 
                In lieu of your response, I'll be hacking a find|sed script to affect the changes.
                 
                Many thanks,
                Andy


                From: fitnesse@yahoogroups.com [mailto:fitnesse@yahoogroups.com] On Behalf Of Rick Mugridge
                Sent: Wednesday, August 01, 2007 7:18 PM
                To: fitnesse@yahoogroups.com
                Subject: Re: [fitnesse] Are Import and DoFixture a Viable Duo?

                Hi Andy,

                The idea of an Import fixture is to avoid including the full class names in tables.

                The idea of DoFixture in flow is to avoid including any class names in tables after the first, plus much much more.

                I fail to see that your first choice below is any better than your second choice. What am I missing?

                Now, if you're not using DoFixture in flow, and want to write class names in all the tables, then starting with an Import makes good sense. However, I must admit to disliking such non-flow storytests, for several reasons. I don't want to expose extraneous implementation detail when I want to talk about business rules, and I want to avoid building such explicit dependencies.  I will give my other reasons if you want...

                Cheers, Rick

                Dassing, Andrew wrote:

                Is there a way to employ an Import fixture in conjunction with a DoFixture?

                To illustrate, the following wiki is the intention, but will not work because the DoFixture must be the first table encountered on the page:

                  !|Import|
                  |com.bubba.gump. fit|

                  !|My Session|
                      :

                Any ideas or suggestions other than:

                  !|com.bubba. gump.fit. MySessionFixture |
                      :

                Many thanks,
                Andy

              Your message has been successfully submitted and would be delivered to recipients shortly.