http://www.vogella.com/articles/JUnit/article.html
1.1. Project preparation
Create a new source folder
test
. For this right-click on your project, select Properties and choose the Java Build Path . Select the Source tab.
Press the
button, afterwards press the button. Create the test
folder.
The result is depicted in the following sceenshot.
(Alternatively you can add a new source folder by right-clicking on a project and selecting
→ .)1.2. Creating JUnit tests
You can write the JUnit tests manually but Eclipse supports the creation of JUnit tests via wizards.
For example to create a JUnit test or a test class for an existing class, right-click on your new class, select this class in the Package Explorer view, right-click on it and select → .
Alternatively you can also use the JUnit wizards available under
→ → → → .
(Wizard for creating test suites
To create a test suite in Eclipse you select the test classes which should be included into this in the Package Explorerview, right-click on them and select → → → .)
1.3. Running JUnit tests
To run a test, select the class which contains the tests, right-click on it and select
→ . This starts JUnit and executes all test methods in this class.
Eclipse provides the Alt+Shift+X, ,T shortcut to run the test in the selected class. If you position the cursor on one method name, this shortcut runs only the selected test method.
To see the result of an JUnit test, Eclipse uses the JUnit view which shows the results of the tests. You can also select individual unit test in this view, right-click them and select Run to execute them again.
1.4. JUnit Content Assists
(JUnit uses static methods and Eclipse cannot always create the corresponding
static import
statements automatically.)
You can make the JUnit test methods available via the Content Assists. Content Assists is a functionality in Eclipse which allows the developer to get context sensitive code completion in an editor upon user request.
Open the Preferences via
→ and select → → → .
Use the new
button to add the org.junit.Assert
type. This makes for example the assertTrue
,assertFalse
and assertEquals
methods directly available in the Content Assists.2) EGit
在Eclipse里使用github的插件
3) Checkstyle 4) Window Builder5) VisualVM
6)Umbrello
For UML diagrams
7)Ant
这里感觉比较干净
ReplyDelete