facebook

Disabling JUnit3 in order to use JUnit4

  1. MyEclipse IDE
  2.  > 
  3. Installation, Configuration & Updates
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #285354 Reply

    pierdeux
    Member

    I cannot get Eclipse to use JUnit 4.4. Instead, JUnit3.x is used.

    • My project and build path contain only the JUnit4 jars.
    • When I choose the “Open Run Dialog…”, JUnit4 is selected as the test runner.
    • I removed the org.junit3 folder from “Program Files/MyEclipse/eclipse/plugins”. (The folder org.junit4 is still there.)

    Yet, it is obvious that the version of JUnit that runs is a variant of version 3 (no recognition of any annotation, etc.).

    I am at a loss as to how to use JUnit4 instead. (Could I please entirely kill, get rid of, destroy, blot out, eliminate JUnit3? This feels like some horror movie sequel, where the zombie keeps coming back again and again…)

    #285356 Reply

    Loyal Water
    Member

    What version of MyEclipse are you working with ?

    Can you go to MyEclipse > Installation Summary > Installation Details and paste the information here for me.

    #285357 Reply

    pierdeux
    Member

    Sorry, I really should have posted that in my original post! 😉 Here it is, below.

    BTW, I would really rather use my own copy of the junit jars than MyEclipse’s. (That’s what I do for the JRE on my project’s classpath, as well as Hibernate jars, Spring jars, etc., never relying on the ones provided with MyEclipse.)

    *** Date: 
    Tuesday, May 27, 2008 12:53:19 o'clock PM EDT
    
    ** System properties:
    OS=WindowsVista
    OS version=6.0
    Java version=1.5.0_11
    
    
    *** MyEclipse details:
    MyEclipse Enterprise Workbench
    Version: 6.0.0 M1
    Build id: 20070629-6.0.0-M1
    
    
    *** Eclipse details:
    MyEclipse Enterprise Workbench
    
    Version: 6.0.0 M1
    Build id: 20070629-6.0.0-M1
    
    
    
    
    Eclipse Platform
    
    Version: 3.3.0.v20070612-_19UEkLEzwsdF9jSqQ-G
    Build id: I20070625-1500
    
    
    Eclipse RCP
    
    Version: 3.3.0.v20070607-8y8eE8NEbsN3X_fjWS8HPNG
    Build id: I20070625-1500
    
    
    Eclipse Java Development Tools
    
    Version: 3.3.0.v20070606-0010-7o7jCHEFpPoqQYvnXqejeR
    Build id: I20070625-1500
    
    
    Eclipse Plug-in Development Environment
    
    Version: 3.3.0.v20070607-7N7M-DUUEF6Ez0H46IcCC
    Build id: I20070625-1500
    
    
    Eclipse Project SDK
    
    Version: 3.3.0.v20070607-7M7J-BIolz-OcxWxvWAPSfLPqevO
    Build id: I20070625-1500
    
    
    Eclipse Graphical Editing Framework
    
    Version: 3.3.0.v20070620
    Build id: 20070620-1021
    
    
    
    
    Eclipse startup command=-os
    win32
    -ws
    win32
    -arch
    x86
    -showsplash
    -launcher
    C:\Program Files\MyEclipse-6.0M1\eclipse\eclipse.exe
    -name
    Eclipse
    --launcher.library
    C:\Program Files\MyEclipse-6.0M1\eclipse\plugins\org.eclipse.equinox.launcher.win32.win32.x86_1.0.0.v20070523\eclipse_1017a.dll
    -startup
    C:\Program Files\MyEclipse-6.0M1\eclipse\plugins\org.eclipse.equinox.launcher_1.0.0.v20070606.jar
    -exitdata
    148c_64
    -vm
    C:\Program Files\MyEclipse-6.0M1\jre\bin\javaw.exe
    #285363 Reply

    Loyal Water
    Member

    Just checked with the dev team, Im not sure if there is a way of disabling JUnit.

    #285364 Reply

    pierdeux
    Member

    Just to make this clear: I don’t want to disable JUnit altogether. I just want to use version 4 (and have nothing to do with version 3).

    #285394 Reply

    Loyal Water
    Member

    When you create a new test case, dont you get the option of creating a new JUnit 3 test and a new JUnit 4 test ?

    #285405 Reply

    pierdeux
    Member

    Well, I never make use of the test wizard. I always create test cases ex nihilo, as I would any normal class (except for the fact that I create it inside a package living inside the “test” folder rather than the “src” folder). I then make this new class extend, say, org.springframework.test.AbstractTransactionalSpringContextTests (or a more proprietary class, as the case may be).

    But that is all neither here not there. The problem comes when I hit Alt-Shift-X T… I don’t feel I have any control on what the TestRunner then launches.

    The reason why I claim that JUnit3 rather than JUnit4 is being run is that my tests behave like JUnit3 tests:
    @Test annotations are ignored,
    @Ignore annotations are ignored,
    @Before annotations are ignored,
    only methods whose name starts with “test” are run,
    “onSetUp()” methods have special status,
    etc.

    #285416 Reply

    Riyad Kalla
    Member

    pierdeux,
    I would never suggest you erase plugins from the install directory in an attempt to get rid of certain functionality. For whatever reason the JUnit test runner that is executing is not detecting your class as a JUnit 4 test case.

    I have quite a few JUnit 4 test cases in projects I have in my workspace and they all run as expected. The key is to make sure the JUnit 4 libraries are in your build path (which you said they already were).

    So me a favor and create a new Java Project, with Java 5 on the build path, then create a simple JUnit 4 test case (that does some siilly stuff) using the new JUnit wizard.

    Run it… does it work?

    Now try to create a new class, manually, using only the JUnit 4 annotations… try and run *it*… does that work?

    #285430 Reply

    pierdeux
    Member

    Thank you, Riyad! Your suggestion helped me discover the source of the problem, and it wasn’t due to Eclipse/MyEclipse…

    The Eclipse TestRunner was indeed choosing JUnit4 (whether I create a class through the wizard or manually), despite what I had assumed.

    The problem stemmed from the base class for most of my tests: org.springframework.test.AbstractTransactionalSpringContextTests, which relies solely on JUnit3.8. As of Spring 2.5, a new testing package was introduced, org.springframework.test.context, which can adapt to any number of different unit testing software, in particular JUnit4.4…

    I’ll get on gradually with switching from the old Spring package to the new one!

    Thank you to all who chipped in!

    #285545 Reply

    Riyad Kalla
    Member

    Glad it’s working now.

Viewing 10 posts - 1 through 10 (of 10 total)
Reply To: Disabling JUnit3 in order to use JUnit4

This topic is marked as closed to new replies, however your posting capabilities still allow you to do so.

You must be logged in to post in the forum log in