Announcement Announcement Module
No announcement yet.
Unrooted Tests, Eclipse, and running individual jUnit 4 Tests Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unrooted Tests, Eclipse, and running individual jUnit 4 Tests

    Another strange item. I am using eclipse, jUnit 4, and I have a number of methods in my test class.

    When I try to run a SINGLE method test, the jUnit view starts, shows THAT test in the window, then creates an "Unrooted tests" entry, and runs ALL the other test methods under that entry.

    I've googled at bit, but I am NOT running these tests as a subclass of TestCase -- I have a base class that extends AbstractTransactionalDataSourceSpringContextTests

    and then the TEST class extends that base class, and uses @Test annotations to delineate the various test methods.

    How do I fix this so that only the SINGLE test I want to run actually executes, and why am I getting the "Unrooted Tests" entry in the jUnit view in eclipse??

  • #2
    Well, to follow up, it looks like if you extend the AbstractTransactionalJUnit4SpringContextTests as the basis of your Test class, you get the "unrooted Test" and the inability to run individual tests.

    Not sure why, but there it is.

    I am trying to update my unit test classes to use the @RunWith(SprintJUnit4ClassRunner.class) stuff, but using that line, I get that the
    "...JUnit4CLassRunner"'s singer information does not match signer information of the other classes in the same package.

    If I OMIT the @RunWith(..) and just start off with the @ContextConfiguration(locations.....), I don't get the error, but the dependency injection doesn't work -- I get null pointers.

    If anyone can shed some light here, I'd appreciate it!


    • #3
      unrooted tests

      Maybe your class extends TestCase (in Junit 3.8 favior,not use the 4.0 annotation), but eclispe will Using the JUnit 4 runner by the default which causes that unrooted test. if you want to use the old Junit 3.8 runner for your 3.8 testcase. you have change the run configurations manually.
      or Maybe your testcase begin whit "test"?
      Last edited by sunly; Mar 31st, 2009, 10:13 PM.


      • #4
        Thanks Sunly -- actually, I DID find out further what the issue was.
        It turns out that both the junit.jar and the junit-4.jar were added to the project I had (it was done automatically). I removed the junit.jar (3.8) from the project, and those "Unrooted tests" stopped.


        • #5
          Perhaps an OO user-error Problem???

          I had the same problem. I am using 3.8 and I have built a framework to run common tests on objects in our project where TestCase is rooted in the heirarchy. One TestCase happens to be implementing an interface and has to override the equals and hashCode methods (for various OO reasons) and the equals method was checking for the wrong instanceof: i.e., my test class is called Foo extends ProjectBaseTest extends TestCast and the equals method of Foo was checking to see if the instance was Bar. In summary, the equals method was alway's returning false. I corrected the implementation of the equals method and Unrooted Tests no longer exists. Check out my blog for a more detailed description: