EclipseImporterDemo

Eclipse Importer Demo

This demo script is part of the NetBeans World Tour 2008 session #2, Using NetBeans For Your Existing Projects.

Main Points to Hit

  • Importing projects from Eclipse is easy!

Prerequisities

  • JDK5 or JDK6
  • NetBeans 5.5 (or higher) - until 6.0 ships it is best to do this demo with 5.5 to show features that are available now  :-)
  • The NetBeans Eclipse Project Importer plugin, available on the update center.
  • Optional: Eclipse (3.2 or higher should work - all testing here was done with 3.3), if you want to show the project being used in Eclipse.

Setup

  1. Download and unzip this file . It contains the source files for the JUnit open source project, downloaded from SourceForge, which includes Eclipse project files (JUnit is an Erich Gamma project - I'm sure he'd be happy to learn how easy it is to start using NetBeans for his JUnit development :-) ).


Demo Steps

  1. Optional: Import the project into Eclipse
    1. File > Import
    2. Expand General and select Existing Projects Into Workspace
    3. Click Next
    4. For the Root Directory select the directory created when you unzipped the file with the JUnit source
    5. In the Projects list make sure junit is selected
    6. Make sure the Copy projects into workspace option is not selected
    7. Click Finish# Optional: Show the project in Eclipse
    8. In Eclipse, select the junit project in the Package Explorer window.
    9. Select Run > Run. Suggested Comment (SC): "This is the source code for the JUnit open source project, checked out from its CVS repository out on SourceForge. It includes Eclipse project files, so I was able to open it up with the project already defined."
    10. In the Run As dialog select Java Application and click OK. SC: "The project definition does not include the run configuration, however, so we'll have to create it now."
    11. Select the JUnitCore - org.junit.runner class as the main class and click OK.
    12. The application runs and produces output that just says: OK (0 tests). SC: "That's not very interesting. Let's have it run its own tests so that we can verify this project is really configured correctly."
    13. Select Run > Open Run Dialog. The entry for JUnitCore should already be selected. Click the Arguments tab and in the Program arguments field specify: org.junit.tests.AllTests.
    14. Click Apply and then click Run.
    15. It takes a few seconds and then it reports: OK (359 Tests) SC: "Ah, much better!"  :-)
  2. Switch over to NetBeans
  3. Select File > Import Project > Eclipse Project. SC: "Now let's use that Eclipse project definition to create a project for JUnit in NetBeans."
  4. Select the Import Project Ignoring Project Dependencies option. SC: "My JUnit Eclipse project does not have any dependencies on other Eclipse projects, so I can import it by itself."
  5. For the Project to Import option select the directory created when you unzipped the file with the JUnit source. SC: "This is the directory that contains the Eclipse project."
  6. For the Destination Folder specify any folder you want - you can even use the same one as the previous step. SC: "I'll tell NetBeans to write its project metadata here."
  7. Click Finish. You'll see an informational dialog - click OK, it is just a heads-up type warning.
  8. Right-click the new project and choose Clean and Build.
  9. Right-click the project and choose Run Project.
  10. Select the same JUnitCore class. SC: "We need to specify a main class."
  11. Click OK. The application runs and produces output that just says: OK (0 tests). SC: "That's not very interesting. Let's have it run its own tests so that we can verify this project is really configured correctly."
  12. Right-click the project and choose Properties.
  13. In the left-pane click Run and then in Arguments specify: org.junit.tests.AllTests
  14. Click OK
  15. Right-click the project and choose Run Project.
  16. It takes a few seconds and then it reports: OK (359 Tests) SC: "Ah, much better!"  :-)


Editing Code

  1. In Eclipise, edit junit.framework.Assert assertTrue method so that it fails (e.g., remove the exclamation point).
  2. Run the project and see the failing tests (145 of them)
  3. Switch to NetBeans and run the project. It will detect the change to Assert.java, compile the file and run. You'll see the same 145 failures.

Task List

  1. Open the task list in Eclipse
  2. Open the task list in NetBeans - it's the same

Demo Cleanup

  • It's easiest to just delete the JUnit project folder and extract it again from the provided archive.
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo