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

Extract superclass refactoring for TestCases

Expand Messages
  • Demyanovich, Craig - Apogent
    How do I create the structure below for some TestCases? TestCase ... MyAbstractTestCase ... ConcreteTestCaseA ConcreteTestCaseB I have common helper
    Message 1 of 5 , Jun 2, 2002
    View Source
    • 0 Attachment
      How do I create the structure below for some TestCases?

      TestCase
      |
      MyAbstractTestCase
      |
      ----------------------
      | |
      ConcreteTestCaseA ConcreteTestCaseB

      I have common helper methods in both ConcreteTestCaseA and
      ConcreteTestCaseB that I want to move to a superclass, thereby removing
      the duplication of the methods. I haven't been able to locate anything
      in the archives for the list, and what I have tried on my own has
      resulted in an error that no tests were found in MyAbstractTestCase. Of
      course, I don't want to write any tests in MyAbstractTestCase.

      Thank you for your time.

      Craig Demyanovich
    • J. B. Rainsberger
      Simple: don t run MyAbstractTestCase, then you won t get the warning. Only run the concrete test cases. That error is just a warning, anyway... ***********
      Message 2 of 5 , Jun 2, 2002
      View Source
      • 0 Attachment
        Simple: don't run MyAbstractTestCase, then you won't get the warning.
        Only run the concrete test cases. That "error" is just a warning,
        anyway...

        *********** REPLY SEPARATOR ***********

        On 2002-06-02 at 13:24 Demyanovich, Craig - Apogent wrote:

        >How do I create the structure below for some TestCases?
        >
        > TestCase
        > |
        > MyAbstractTestCase
        > |
        > ----------------------
        > | |
        > ConcreteTestCaseA ConcreteTestCaseB
        >
        >I have common helper methods in both ConcreteTestCaseA and
        >ConcreteTestCaseB that I want to move to a superclass, thereby
        removing
        >the duplication of the methods. I haven't been able to locate
        anything
        >in the archives for the list, and what I have tried on my own has
        >resulted in an error that no tests were found in MyAbstractTestCase.
        Of
        >course, I don't want to write any tests in MyAbstractTestCase.
        >
        >Thank you for your time.
        >
        >Craig Demyanovich
        >
        >
        >------------------------ Yahoo! Groups Sponsor
        ---------------------~-->
        >Tied to your PC? Cut Loose and
        >Stay connected with Yahoo! Mobile
        >http://us.click.yahoo.com/QBCcSD/o1CEAA/sXBHAA/5cFolB/TM
        >---------------------------------------------------------------------~-
        >
        >
        >To unsubscribe from this group, send an email to:
        >junit-unsubscribe@yahoogroups.com
        >
        >
        >Your use of Yahoo! Groups is subject to
        http://docs.yahoo.com/info/terms/


        J. B. Rainsberger,
        President, Diaspar Software Services
        Let's write software that people understand.
        http://www.diasparsoftware.com/
        telephone: +1 416 791-8603
      • Craig Demyanovich
        Since I use Ant to run all TestCases in the test directory, I can easily exclude MyAbstractTestCase. Simple, indeed. Although, I d still like to hear other
        Message 3 of 5 , Jun 2, 2002
        View Source
        • 0 Attachment
          Since I use Ant to run all TestCases in the test directory, I can easily
          exclude MyAbstractTestCase. Simple, indeed. Although, I'd still like
          to hear other ideas if anyone has them.

          Thanks, J.B.

          Craig

          -----Original Message-----
          From: J. B. Rainsberger [mailto:jbr@...]
          Sent: Sunday, June 02, 2002 5:17 PM
          To: junit@yahoogroups.com
          Subject: Re: [junit] Extract superclass refactoring for TestCases


          Simple: don't run MyAbstractTestCase, then you won't get the warning.
          Only run the concrete test cases. That "error" is just a warning,
          anyway...

          *********** REPLY SEPARATOR ***********

          On 2002-06-02 at 13:24 Demyanovich, Craig - Apogent wrote:

          >How do I create the structure below for some TestCases?
          >
          > TestCase
          > |
          > MyAbstractTestCase
          > |
          > ----------------------
          > | |
          > ConcreteTestCaseA ConcreteTestCaseB
          >
          >I have common helper methods in both ConcreteTestCaseA and
          >ConcreteTestCaseB that I want to move to a superclass, thereby
          removing
          >the duplication of the methods. I haven't been able to locate
          anything
          >in the archives for the list, and what I have tried on my own has
          >resulted in an error that no tests were found in MyAbstractTestCase.
          Of
          >course, I don't want to write any tests in MyAbstractTestCase.
          >
          >Thank you for your time.
          >
          >Craig Demyanovich
          >
          >
          >------------------------ Yahoo! Groups Sponsor
          ---------------------~-->
          >Tied to your PC? Cut Loose and
          >Stay connected with Yahoo! Mobile
          >http://us.click.yahoo.com/QBCcSD/o1CEAA/sXBHAA/5cFolB/TM
          >---------------------------------------------------------------------~-
          >
          >
          >To unsubscribe from this group, send an email to:
          >junit-unsubscribe@yahoogroups.com
          >
          >
          >Your use of Yahoo! Groups is subject to
          http://docs.yahoo.com/info/terms/


          J. B. Rainsberger,
          President, Diaspar Software Services
          Let's write software that people understand.
          http://www.diasparsoftware.com/
          telephone: +1 416 791-8603



          To unsubscribe from this group, send an email to:
          junit-unsubscribe@yahoogroups.com


          Your use of Yahoo! Groups is subject to
          http://docs.yahoo.com/info/terms/
        • Parag Shetye
          I used the sort of similar structure using JFunc, see if it is useful. Corrections are welcome. MyAbstractTestCase ... ConcreteTestCaseA ConcreteTestCaseB
          Message 4 of 5 , Jun 2, 2002
          View Source
          • 0 Attachment
            I used the sort of similar structure using JFunc, see if it is useful.
            Corrections are welcome.

            MyAbstractTestCase
            |
            ----------------------
            | |
            ConcreteTestCaseA ConcreteTestCaseB

            ConcreteTestCaseA and ConcreteTestCaseB extends MyAbstractTestCase.
            There is also a helper class along with ConcreteTestCaseA.

            Now, in ConcreteTestCaseA or ConcreteTestCaseB u can write code as given
            below.

            --------------------------------------------------------------------
            public static Test suite()throws Exception{

            JFuncSuite suite = new JFuncSuite();
            suite.setName("My Test Suite");
            suite.oneTest(true);

            ConcreteTestCaseA test = new ConcreteTestCaseA();
            test = (ConcreteTestCaseA) suite.getTestProxy(test);

            //Temp fix me - due to limitation of JFunc cannot load base
            class methods as a part of proxy
            MyAbstractTestCase test2 = new MyAbstractTestCase();
            test2 = (MyAbstractTestCase)
            suite.getTestProxy(MyAbstractTestCase);

            Note: Imports used -
            -----
            import junit.framework.*;
            import junit.runner.BaseTestRunner;
            import junit.extensions.ExceptionTestCase;
            import junit.extensions.jfunc.*;

            // Helper classes if kept in diff folder.
            import test.helper.*;

            ---------------------------------------------------------------------

            This will create 2 proxies - test and test2 pointing to
            ConcretetestCaseA and MyAbstractTestCase respectively.
            So whenever you want to execute methods (actual testcases) in
            ConcreteTestCaseA use test.methodName()
            also whenever you want to execute methods in MyAbstractTestCase use
            test2.methodName()

            This type of proxies are used due to the limitation of JFunc. We are
            trying to fix and submit it.

            Regards,
            Parag



            "Demyanovich, Craig - Apogent" wrote:

            > How do I create the structure below for some TestCases?
            >
            > TestCase
            > |
            > MyAbstractTestCase
            > |
            > ----------------------
            > | |
            > ConcreteTestCaseA ConcreteTestCaseB
            >
            > I have common helper methods in both ConcreteTestCaseA and
            > ConcreteTestCaseB that I want to move to a superclass, thereby
            > removing
            > the duplication of the methods. I haven't been able to locate
            > anything
            > in the archives for the list, and what I have tried on my own has
            > resulted in an error that no tests were found in MyAbstractTestCase.
            > Of
            > course, I don't want to write any tests in MyAbstractTestCase.
            >
            > Thank you for your time.
            >
            > Craig Demyanovich
            >
            >
            > To unsubscribe from this group, send an email to:
            > junit-unsubscribe@yahoogroups.com
            >
            >
            > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.





            [Non-text portions of this message have been removed]
          • pholser
            ... i have found myself naming abstract test classes AbstractXyzTest , where Xyz is the name of the class under test. this makes excluding abstract test
            Message 5 of 5 , Jun 2, 2002
            View Source
            • 0 Attachment
              --- In junit@y..., "Craig Demyanovich" <demmer12@m...> wrote:
              > Since I use Ant to run all TestCases in the test directory,
              > I can easily exclude MyAbstractTestCase.

              i have found myself naming abstract test classes "AbstractXyzTest",
              where Xyz is the name of the class under test. this makes excluding
              abstract test classes from execution via Ant a simple exercise.
              i think you're on a good path.

              --p

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