Plugin to make maintaining JUnit tests a little less painful.
Agile methodologies put a great emphasis on test automation. Kent Beck, one the father of XP, and Erich Gamma have written what is now the defacto framework for unit test automation, the XUnit framework family. It has been ported to many languages, its java incarnation being junit. The framework has many features that simplify the boring mechanics of testing: test case organization, set up, execution and result reporting. If you are not familiar with junit please read its cookbook. You also can find more on XP and unit testing here.
IDEA has a junit integration that simplify the testing process one step further:
- One click away run of one test method, all tests in one class, all tests in one package tree
- Navigation back to the source from assertion stack traces
- Keeps a list of test configuration for immediate rerun
- Aurora has now a much nicer graphical runner.
However there are several key area not covered that this plugin intends on addressing:
- Provide a way to define a project wide organization of test case with respect to the classes/methods they test
- Provide fast navigation between test element and tested element and vise-versa. This is even more important since IDEA does not have the ability yet to display tested element and test element side by side (multiple file editor splitting)
- Provide automatic creation of the test elements (Test class and methods) following customizable templates
- Keep in sync the names and location of test elements as the tested elements are renamed and moved.
- Provide visual feedback whether or not a method does not have test in the editor.
- Enhanced text ui to provide better visual feedback of test suite run status.
- Provide documentation on the Class Under Test from the test methods name
This plugin uses an unsupported IDEA api, the ProgramStructureInterface. Since the PSI hasn't stabilize enough to be part of the OpenAPI, the plugin could be broken for any new build. Do not send bug report to the tracker. Just post to the plugins news group or email me if you have an urgent problem.
Please read the ProgramStructureInterface disclaimer.
Special thanks for Bronwen Cassidy who is helping a lot. She introduced the velocity template generation of the test class. Thanks for your passion to innovate and learn.
The current implementation of the plugin is based on MikeAizatsky's generous donation of his junit test plugin (see PsiIntroduction).
See JUnitTestPluginUserGuide
Download from the Attachements section the proper version of the plugin zip for your IDEA version and extract it to *IDEA_DIR/plugins*
Make sure that you have the following directory layout:
IDEA_DIR/plugins
unitTest
lib
unitTest.jar
commons-lang-1.0.jar
- Version temporarily uploaded here for IDEA 4.0 - 4.5
- Fix incorrect identification of test class as class to be tested in multi-module projects
- Fix Test method with exception template
- Fix toggle not working all the time => create new test class
- Fix button to go from config to template editor
- Upgraded to 992
- Added validity check for patterns (reported by Thomas Svensen)
- Upgraded to 977
- Fixed dot in class name while the pattern is w/o $DIRECTORY$
- Added method templates
- Fix NPE in UntestedMethodHighligter? (reported by Michal Szklanowski)
- Migrate to 944
- Recompiled for 929 (fixed the broken auto-refactoring)
- Fix the deadlock on second project load
- Fix NPE when loading second project
- Fix wrong test class location if directory path contains '.' (Reported by M. J. Milicevic)
- Fix icons in test template selection panel
- Recompiled for 915
- Fix creating test class in the wrong location when roots paths are overlapping (c:/src & c:/src-test, c:/src & c:/src/test) (reported by Chris Winters)
- Add multiple test class template support. On Ctrl-Shit-T a choice of template to use will be presented (in place of the yes/no question)
- Add option to bypass the template choise popup when there is only one test template
- Fix to class creation problem (reported by Chris Winters)
- Fix template variable name of the test class (was CLASS_NAME and is now NAME like the normal IDEA class template)
- Fix NPE on cancel of choosing the template used (reported by Bas Leijdekkers)
- Fix "File Header" include not found if it isn't modified
- Fix the changing of the test pattern only affecting the navigation and creation of test class/method and not
untested method highlighting and auto-refactoring (reported by Bas Leijdekkers)
- Change pattern $PACKAGE$ variable to $DIRECTORY$ to avoid confusion since this will match any directory
whether it is a package or just a directory
- Add template variables USER, DATE, TIME, TESTED_CLASS_NAME, TESTED_CLASS_PACKAGE_NAME
- Change settings to go to the workspace instead. This makes sharing the project file easier.
- Add test class velocity template generation
- Fix the intermittent assertion in isUnitTest() (reported by Bas Leijdekkers & Debabrata Dash)
- Upgraded to 833 (not backward compatible)
- Gutter icons are now refreshed automatically as you type
- Fixed NPE when editing Default Project properties
- Upgraded to 811 (not backward compatible)
- Gutter icon is clickable which create/navigate to test method
- Upgraded to 811 (not backward compatible)
- Fixed getter highlight options bug
- Fixed renaming/moving test class refactoring. These refactorings won't change any references to the test classes (they do not use IDEA refactoring anymore due to an unsolvable problem). This is only a problem though when a static suite is used.
- Mark Untested methods with little red icon in the editor left gutter (Special thanks for BronwenCassidy to make it work)
- NOTE: if you get a NPE while renaming/moving a class that seems unrelated to the plugin please turn off the automatic refactoring and see if it fixes the exception. If not restart IDEA. The next release will address this.
- Added automatic renaming of test methods if associated tested method is renamed.
- Better help on patterns from the property panel
- Added automatic moving of test class if associated tested class is moved (through Move refactoring).
- Fix bug preventing to rename any class w/o a test (Thanks DaveGriffith for reporting it)
- Added support for test navigation in the Project and Structure tool window
- Added automatic renaming of test class if associated tested class is renamed (through Rename refactoring).
- Migrate to Aurora
- Added invitro tests to test the refactoring support
- Added version number in the plugin properties panel
- Beef up the build.xml and introduced a build.properties to customize paths
- Fix navigation to properly handle tested methods combination where one tested method name is completely included in another like
myMethod in myMethodWithExtraWords
- Fix bug that prevented a test method to be created when not found.
- Toggle does not move cursor if it is already inside target method
- Recognize test methods with things after the tested method name like
testMyMethodWithNullParam or testMyMethod_Success
- Fix few bugs (structure popup menu item name, plugin properties pattern description)
- Set a default pattern ($CLASS%-> test/$CLASS% which is my prefered pattern
)
- Fix internal error on startup
- Move the go to menu to the Go To top level menu and the editor popup Go to
- Fix not firing a ModificationAttemptListener? when trying to create a test method on a readonly test class file (Should be done by PSI automatically IMHO). This allows other plugin a chance to make the file writable (ClearCasePlugin will offer to check out the file for example)
- Fix missing import statement on newly create TestCase?
- Ctrl-T inside a method toggles between tested method and test method and vise-versa
- Create test class and test method automatically
- Supports a flexible test organization definition (See How To Use)
See JUnitTestPluginRequests for the list of tasks.
Please feel free to add your own and vote the existing ones.
You can turn the plugin debugging logging by modifying IDEA_DIR/bin/log.xml and append the following tags at the end:
<category name="org.intellij.plugins.junit">
<priority value="DEBUG"/>
<appender-ref ref="CONSOLE-DEBUG"/>
<appender-ref ref="FILE"/>
</category>
The FILE appender will output the trace to the system log file located at $SYSTEM_DIR$/log/idea.log. $SYSTEM_DIR$ is on Win32 at C:\Documents and Settings\#USER_NAME#\.IntelliJIdea\system
-- JacquesMorel - 08 Nov 2002
|
|