5 Replies Latest reply on Oct 27, 2009 7:37 PM by James Carr

    JUnit 4?

    James Carr Newbie

      As someone who has recently started working with the HornetQ codebase, I was quite surprised to see that JUnit3 is still being used.

      Any reason we can't go ahead and bump tests up to use JUnit4? Junit4 has a ton of useful features plus breaks the need to extend a base class in test cases.

      Also, if you run all tests with Junit3 and Junit4, they will all run, so there's no need to worry about having to convert all the tests right away to JUnit4. Thoughts?


        • 1. Re: JUnit 4?
          Clebert Suconic Master

          I guess we just didn't upgrade it because we were focusing on other things.

          Maybe we should do it after GA. I'm just afraid about side effect problems and having to spend time debugging tests that stopped working because of semantic changes on JUnit. I'm not sure if 100% sure we could guarantee the same semantics between JUnit 3 and 4. (setUp, tearDown, suite.. etc)

          • 2. Re: JUnit 4?
            Andy Taylor Master

            Why don't you raise a JIRA and mark it against 2.1. We (you ;)) can do it then :)

            • 3. Re: JUnit 4?
              Clebert Suconic Master

              @Jamescarr... Not that I was intentionally googling you. (I actually also saw a few of your messages on twitter about testing.. that's why I was googling some of the stuff you did post on twitter).

              You seem to blog a lot about Testing:

              If someone google for "Test Anti Pattern" you will have your blog post as the first one in line :-)



              In particular I saw you blogging a lot about Mocking frameworks a la EasyMock. Something you called Mockito.

              So, besides Junit4, what other upgrades you would make to our testsuite?

              We used to use EasyMock, but it wasn't a good experience.

              Also.. what about TestNG? Do you have any experience with it? It seems the same as JUnit to me, and since all the IDEs have plugins for it we never thought about any other options...

              Anyway.. I just wanted to use this opportunity to hear your ideas ;-)


              • 4. Re: JUnit 4?
                Tim Fox Master

                I agree with Clebert.

                It would be nice to upgrade to Junit 4, but I don't think it is a priority right now for the GA release, since Junit 3 works.

                We could certainly look at this after 2.0 if someone adds a JIRA...

                • 5. Re: JUnit 4?
                  James Carr Newbie

                  Hi Clebert,

                  I've used mocking frameworks for about 4 years... after using JMock, RMock, and EasyMock, I decided they they were all more hassle than they were worth and ditched them for hard coded Mock implementations of interfaces.

                  Mockito is the one framework that finally made me leave the world of hard coded mocks again as it's simple and elegant... and has none of that replay nonsense. I could pick a test from the code base and rework it with Mockito and post the resulting test here if there's interest. ;)

                  As for TestNG... I've tried it, but never found it interesting/useful enough to switch from JUnit4. :)

                  As for breaking JUnit3 tests, in my experience JUnit3 tests run just fine with the JUnit4 runner... the TestCase class is the same as it is in JUnit3, Junit4 tests just use annotations instead of extending TestCase.

                  I'll put a JIRA issue in for it. ;)