GeoTools
  1. GeoTools
  2. GEOT-3008

Add JUnit 4 support for online tests

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.6.3, 2.7-M0
    • Fix Version/s: 2.6.3, 2.7-M0
    • Component/s: None
    • Labels:
      None

      Description

      Attached patch adds JUnit 4 online test support through a new class OnlineTestSupport.

      From the javadoc: "This class is an adapter to OnlineTestCase that allows its use with JUnit 4. Delegation is used to recycle the behaviour of OnlineTestCase without extending TestCase. This is necessary because TestRunners appear to give priority to JUnit 3 behaviour, ignoring JUnit 4 annotations in suites that extend TestCase."

      -------- Original Message --------
      Subject: [ExternalEmail] [Geotools-devel] OnlineTestCase and JUnit 4
      Date: Tue, 23 Mar 2010 17:36:57 +0800
      From: Ben Caradoc-Davies 
      To: Geotools-Devel list
      
      OnlineTestCase extends JUnit 3 TestCase. The TestRunners I have been 
      using ignore JUnit 4 annotations on classes that extend JUnit 3 
      TestCase, leading to suites with no tests.  :-(
      
      As I extend my offline JUnit4 tests to have online parts, I dutifully 
      refactor the online parts into OnlineTestCases, but it feels like I am 
      backporting to JUnit 3 (probably because I am).
      
      Do we need a JUnit 4 equivalent of OnlineTestCase? OnlineTestSupport, 
      perhaps?
      
      -- 
      Ben Caradoc-Davies
      Software Engineering Team Leader
      CSIRO Earth Science and Resource Engineering
      Australian Resources Research Centre
      

        Activity

        Hide
        Ben Caradoc-Davies added a comment -
        Jody, could you give me a quick sanity check on this new class? (Or recommend someone who can?)

        sample-data has no active maintainer. :-(

        I will commit to trunk and 2.6.x if you think this looks OK.
        Show
        Ben Caradoc-Davies added a comment - Jody, could you give me a quick sanity check on this new class? (Or recommend someone who can?) sample-data has no active maintainer. :-( I will commit to trunk and 2.6.x if you think this looks OK.
        Hide
        Jody Garnett added a comment -
        I had not run into Assume.assumeNotNull before; I think this patch does what you set out to do... but I am really scared of checking a connection for each and every test. If we are depending on a timeout for example it would get messy quick.

        Still for the common case of a fixture not being configured there should be no pain. I assume because this is a test case we need no test case :-P

        Please go ahead and commit.
        Show
        Jody Garnett added a comment - I had not run into Assume.assumeNotNull before; I think this patch does what you set out to do... but I am really scared of checking a connection for each and every test. If we are depending on a timeout for example it would get messy quick. Still for the common case of a fixture not being configured there should be no pain. I assume because this is a test case we need no test case :-P Please go ahead and commit.
        Hide
        Ben Caradoc-Davies added a comment -
        Assume is very useful. JUnit 4 fixes so many things. Blame Gabriel :-) , who helped us out with app-schema when we got it into GeoServer 2.0, and in the process, convinced me that JUnit 4 was worth the effort. Between Assume and @BeforeClass, JUnit 4 makes fixture setup and one-time-setup so much easier.

        I checked again and I realised that the behaviour of this class does not have the subtle difference mentioned in the javadoc. It behaves exactly the same as OnlineTestCase, and will call connect() for every test, just like OnlineTestCase. If there is any scariness, it is no more than OnlineTestCase. I removed the last paragraph of the javadoc from the patch.

        I did contemplate writing a unit test, but it would have to be an online unit test, and require multiple fixtures to test the behaviour variations.

        Committed as r35105 on trunk and r35106 on 2.6.x.
        Show
        Ben Caradoc-Davies added a comment - Assume is very useful. JUnit 4 fixes so many things. Blame Gabriel :-) , who helped us out with app-schema when we got it into GeoServer 2.0, and in the process, convinced me that JUnit 4 was worth the effort. Between Assume and @BeforeClass, JUnit 4 makes fixture setup and one-time-setup so much easier. I checked again and I realised that the behaviour of this class does not have the subtle difference mentioned in the javadoc. It behaves exactly the same as OnlineTestCase, and will call connect() for every test, just like OnlineTestCase. If there is any scariness, it is no more than OnlineTestCase. I removed the last paragraph of the javadoc from the patch. I did contemplate writing a unit test, but it would have to be an online unit test, and require multiple fixtures to test the behaviour variations. Committed as r35105 on trunk and r35106 on 2.6.x.

          People

          • Assignee:
            Jody Garnett
            Reporter:
            Ben Caradoc-Davies
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: