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
- 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
- Optional: Import the project into Eclipse
- File > Import
- Expand General and select Existing Projects Into Workspace
- Click Next
- For the Root Directory select the directory created when you unzipped the file with the JUnit source
- In the Projects list make sure junit is selected
- Make sure the Copy projects into workspace option is not selected
- Click Finish# Optional: Show the project in Eclipse
- In Eclipse, select the junit project in the Package Explorer window.
- 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."
- 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."
- Select the JUnitCore - org.junit.runner class as the main class and 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."
- 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.
- Click Apply and then click Run.
- It takes a few seconds and then it reports: OK (359 Tests) SC: "Ah, much better!" :-)
- Switch over to NetBeans
- Select File > Import Project > Eclipse Project. SC: "Now let's use that Eclipse project definition to create a project for JUnit in NetBeans."
- 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."
- 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."
- 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."
- Click Finish. You'll see an informational dialog - click OK, it is just a heads-up type warning.
- Right-click the new project and choose Clean and Build.
- Right-click the project and choose Run Project.
- Select the same JUnitCore class. SC: "We need to specify a main class."
- 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."
- Right-click the project and choose Properties.
- In the left-pane click Run and then in Arguments specify: org.junit.tests.AllTests
- Click OK
- Right-click the project and choose Run Project.
- It takes a few seconds and then it reports: OK (359 Tests) SC: "Ah, much better!" :-)
Editing Code
- In Eclipise, edit junit.framework.Assert assertTrue method so that it fails (e.g., remove the exclamation point).
- Run the project and see the failing tests (145 of them)
- 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
- Open the task list in Eclipse
- 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.
Attachments
