How to delete Junit3 support in eclipse? - eclipse

I am using a freshly downloaded eclipse (eclipse-jee-oxygen-3a-win32-x86_64) from eclipse.org.
When I create a new JUnit Test Case using the wizard, then the wizard allows to add a "New JUnit 3 test".
Additionally when I am inside my test class and want to add a new test method via writing test and hitting Ctrl+Space then the template shown above is "test3".
How can I remove JUnit 3 support completely from my eclipse?
Or even better, since we also use a pre-configured eclipse installed via the eclipse-installer (oomph), how can I avoid to install it in the first place? Our oomph installation is based on package epp.package.jee.

Use eclipse-jee-oxygen-M2-win32-x86_64 from eclipse.org.
You can download it from http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/oxygen/M2/eclipse-jee-oxygen-M2-win32-x86_64.zip
When you will create a new Junit Test Case using the wizard. It will not add Junit 3 support instead It will add Junit 4.

Related

Run multiple RCP junit tests encompassed in multiple bundles

We have multiple RCP bundles and seperate fragment projects to test these bundles with either RCP plugin or plain jUnit tests.
Problem
To test the well functioning of the whole ecosystem we would like to run all tests from all plugins before we push new code to our CI environment.
Yet, till now we only figured out how to run the tests inside single projects at once. Thus, to run all tests on all plugins we currently select one plugin at a time and execute the tests inside via the context menu. This manual process is error-prone.
Question
Is there a way in the eclipse IDE to run all tests inside all plugin projects at once?
The easiest way is to create a Launch Group; you can find it under Debug Configurations.
Add all your existing JUnit (or JUnit Plug-in Test) launch configurations to it and then hit the Debug button.
Unfortunately if you create additional JUnit Plug-in tests after this Launch Group was created, then you have to add those new Plug-ins manually.

Disable import of JUnit 3 classes

I want to develop JUnit 4 tests only. When writing Unit Tests, Eclipse often imports classes from junit.framework, which is JUnit 3.
This has lead to various problems, e.g. when expecting an Exception, it simply doesn't catch it if it's in the wrong package like this:
import static org.junit.Assert.*;
import junit.framework.ComparisonFailure;
[...]
try
{
assertEquals(0, 1);
}
catch(ComparisonFailure cfe)
{
}
Strange enough, if I Ctrl+Click on ComparisonFailure, it says
Source not found
The JAR of this class belongs to container 'JUnit 4' [...]
Perhaps helpful environment information:
I don't have JUnit 3 in my build path.
Eclipse Luna 4.4.1
How can I stop Eclipse from importing JUnit 3 classes?
I have read Why is Eclipse using JUnit 3 when I have junit-4.3.1.jar in my build path?, but it's rather old and probably does not apply to Luna any more. Also, my problem is not in running the test, it's in implementing the test.
Another workaround for Eclipse's users is the following solution:
Windows -> Preferrences -> Java -> Appearance -> Type filters
and add junit.framework.* to the exclusion list.
Actually, JUnit 4 depends on some of the classes that were developed originally within JUnit 3 or reside in packages junit.*. One of such class is ComparisonFailure. If you look at latest JUnit 4.12 you will see that these packages are still there.
However, sources jar do contain java files for these classes. Perhaps your library that contains JUnit (do you use Eclipse JUnit library?) lacks source files for these? Where does your dependency (junit.jar) come from?
Which dependencies has your plugin ? Junit 3.X or 4.X ?
You could search your workspace for any references in junit 3 and change/remove them.

How to run a JUnit test in eclipse?

I'm using eclipse and I have downloaded a JUnit test, and imported it into my package that I'm currently working on.
However instead of showing test.java it shows test.java.txt. And when I click 'Run as', JUnit test does not come up as one of the options.
Thank you in advance for your help.!
For the "Run as JUnit" option to appear, the file must be a Java file (extension .java).
JUnit scans your class for test methods. Depending on the version of JUnit that you're using, it can be done in multiple ways. JUnit before version 4.0 requires your test methods' names to start with the word test; with JUnit 4.0 onwards, you can use annotations to designate your test methods.
If your code contains JUnit annotations (such as #Test), but JUnit still complains that it can't find any test methods, then it means that you're running JUnit 3.x and not JUnit 4.x.

How-to integrate gUnit ( ANTLR grammar testing ) in the NetBeans build cycle?

Background: I am using NetBeans 7.1 and ANTLR 3.4. I have integrated java code generation in the NetBeans build script using the following tutorial: http://wiki.netbeans.org/Integrating_ANTLR_without_learning_Ant. I want to use automated tests for testing grammars. I have read about gUnit on the ANTLR site. There are, supposedly, two modes: one 'direct' method and another method which generates jUnit code. I have worked with jUnit before.
Question(s):
What method is advisable? Direct or via jUnit? Or perhaps both?
What should I do to integrate gUnit in the NetBeans build cycle?
My personal preference is to use JUnit since then you can run the generated tests like any other JUnit test in NetBeans.
To get the JUnit classes you need to run the org.antlr.gunit.Interp class (in the Antlr JAR) as a Java program with the -o flag. The result will be JUnit classes in the same dir as the gunit file. Add the generated source to your project and compile/run.

How to simply add jar files, as libraries in a Netbeans module suite?

I'm a bit confused with NetBeans (versions 6.5 and 6.7). I have a NetBeans Module Suite application, which consists of several NetBeans Modules. I need to add some code in one of the modules. The new code is using a library, distributed as several jar files.
The problem is, that NetBeans does not allow me to add this library jars directly to the classpath. It wants to wrap all the jars in a new Library Wrapper Module, which is then added to the project and used from there. The effect is that all the original jars are combined into a single new jar automatically by NetBeans. This is a problem, because I can't just replace the jars later, without rebuilding this "Library Wrapper Module" and the original library is updated nightly.
I read some NetBeans forums, but I found nothing... I tried with simple java application, where it is possible to simply add jar(s) to the classpath using Project Properties -> Libraries -> Add JAR/Folder. If you use a NetBeans module instead of a simple application, the Libraries dialog looks different and does not have the "Add JAR/Folder" button.
Is it possible to add a plain normal jar in a NetBeans module and how?
It looks like the way a user can wrap a jar has changed in NetBeans 6.8.
Since this has been integrated into a property dialog of a project, the build process might be smarter, too. And it seems like that was your primary concern....