Getting Started: Creating New JUnit Tests
The following instructions guide you through the creation of a JUnit test case using CoViewDeveloper. It assumes your workspace already contains a project with classes that you want to test as well as the necessary JUnit jar file.1. Make the CoView Editor the default Java Editor. Select Window > Preferences > General > Editors > File Associations
Getting Started
- 1. Open the CoView Perspective. Select CoView > Open Perspective. This changes the Eclipse perspective to the one used by CoView.
- 2. In the Package Explorer, right click on a class and select CoView > Create CoView JUnit Test Case.
- The New CoView JUnit Test Case window is displayed.
- JUnit Version: Identifies the JUnit version used to create tests.
- Source Folder: Identifes the source folder within the project that will contain the test case.
- Package: Identifies the Java package to which the test case belongs.
- Name: Identifies the name of the test case class to be created.
- SuperClass: Identifies the class which the test case extends.
- Create Mock Object Stubs 'None': No JMockit code will be added to the generated test case.
- Create Mock Object Stubs 'Empty' : basic JMockit code for setting expectations and additional verification.
- Create Mock Object Stubs 'For Method Arguments (only interfaces)': in addition to basic JMockit code, a corresponding JMockit stub is added for every method argument of interface type. It is up to the user to define the concrete expecte invocations and return values.
- Create Mock Object Stubs 'For Method Arguments (interfaces and classes)': The same as above but with support for classes as arguments.
- Also generate mocks for all invocations lying on corresponding path: This option is available when For Method Arguments (interfaces and classes) is selected. This option automatically creates all mock object stubs for each path within a method.
- 3. Select Next on the wizard to proceed.
- Add method invocations using. The toggle indicates that the generated test methods should contain invocations of the methods under test. If this toggle is enabled, an instance of the class under test is needed to invoke the non-static methods under test. Use the drop-down list to select a constructor which will be used to instantiate the class under test.
- Available Methods: Select the methods you wish to create JUnit tests for. CoView inserts proxy code to allow testing private methods.
- 4. Select Finish to continue.


At this point the test case is created and the CoView JUnit Runner is automatically started. You may need to complete the generated Mock Objects to fully test complex paths.Testability, coverage and JUnit summary metrics can be reviewed by looking at the CoView Quality Manager view or CoView JUnit Manager view, and the tested path(s) can be identified in the CoView JUnit Developer view.
The generated test case can be found in the location specified in step 1 above and displayed in the CoView Editor.