Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Static imports (JUnit)
Static imports (JUnit) [message #258205] Wed, 21 January 2009 15:31 Go to next message
Eclipse UserFriend
Hi,

if I remember correctly Eclipse is able to add automatically the static
import statements to a class. At the moment I'm not able to make this
work. I have the following class:

--------
package de.vogella.jpa.eclipselink.main;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class ImportTest {
@Test
public void testIt() {
assertTrue(true);
}
}
-----------

If I remove the import static org.junit.Assert.assertTrue; neither
"Organize Imports - Cntrl + Shift + O " or "Add Import - Cntrl + Shift +
M) add them.

Any advice how to use Eclipse to automatically add the static import
statements?

Best regards, Lars
Re: Static imports (JUnit) [message #258221 is a reply to message #258205] Thu, 22 January 2009 03:25 Go to previous messageGo to next message
Eclipse UserFriend
Lars Vogel wrote:
> Hi,
>
> if I remember correctly Eclipse is able to add automatically the
> static import statements to a class. At the moment I'm not able to
> make this work. I have the following class:
>
> --------
> package de.vogella.jpa.eclipselink.main;
>
> import static org.junit.Assert.assertTrue;
>
> import org.junit.Test;
>
> public class ImportTest {
> @Test
> public void testIt() {
> assertTrue(true);
> }
> }
> -----------
>
> If I remove the import static org.junit.Assert.assertTrue; neither
> "Organize Imports - Cntrl + Shift + O " or "Add Import - Cntrl + Shift
> + M) add them.
>
> Any advice how to use Eclipse to automatically add the static import
> statements?
Organize Imports cannot do this. What you can do is to add
'org.junit.Assert' (or only some of its methods) to the Java > Editor >
Content Assist > Favorites preference page. If yo do this you can then
use Content Assist (Ctrl+Space) to add the method and the import.

Dani
>
> Best regards, Lars
>
Re: Static imports (JUnit) [message #258225 is a reply to message #258221] Thu, 22 January 2009 18:41 Go to previous message
Eclipse UserFriend
Hi Daniel,

thank you & Best regards, Lars

Daniel Megert wrote:

> Organize Imports cannot do this. What you can do is to add
> 'org.junit.Assert' (or only some of its methods) to the Java > Editor >
> Content Assist > Favorites preference page. If yo do this you can then
> use Content Assist (Ctrl+Space) to add the method and the import.
>
> Dani
Previous Topic:Display the problems related to a Java project
Next Topic:Weird plugin classloading problem (I think)
Goto Forum:
  


Current Time: Sat Jun 07 04:56:09 EDT 2025

Powered by FUDForum. Page generated in 0.02858 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top