IntelliJ Community . JUnitGenerator

 
JUnitGenerator 

HOME INDEX SEARCH CHANGES GO  

JUnitGenerator

Purpose

This is very simple plugin that generates JUnit test case skeleton including all the methods of tested class. Here is an example:

Tested Class:

package org.intellij.plugins.junitgen; 
 
public class MyClass 
{ 
    public Object getSomePublicValue(){ 
        ... 
    } 
 
    protected Object getSomeProtectedValue(){ 
        ... 
    } 
 
    Object getSomeDefaultValue(){ 
        ... 
    } 
} 

Test Case:

package org.intellij.plugins.junitgen; 
import junit.framework.Test; 
import junit.framework.TestSuite; 
import junit.framework.TestCase; 
/** 
 * MyClass Tester. 
 * 
 * @author <Authors name> 
 * @since <pre>09/04/2003</pre> 
 * @version 1.0 
 */ 
public class MyClassTest extends TestCase 
{ 
    public MyClassTest(String name) 
    { 
        super(name); 
    } 
 
    public void setUp() throws Exception 
    { 
        super.setUp(); 
    } 
 
    public void tearDown() throws Exception 
    { 
        super.tearDown(); 
    } 
 
    public void testGetSomePublicValue() throws Exception 
    { 
        //TODO: Test goes here... 
    } 
 
    public void testGetSomeProtectedValue() throws Exception 
    { 
        //TODO: Test goes here... 
    } 
 
    public void testGetSomeDefaultValue() throws Exception 
    { 
        //TODO: Test goes here... 
    } 
 
    public static Test suite() 
    { 
        return new TestSuite(MyClassTest.class); 
    } 
} 

If the plugin finds that the test case already exists it prompts you to choose Overwrite or Diff using JDiffFile? plugin.
You can customize the output by modifying junitgen.vm velocity template. All available variables are listed in the template.
Also you can configure the output pattern by modifying junitgen.properties which has following the properties defined:

1. $SOURCEPATH$ - the source path of the tested file. i.e c:/src/junitgen
2. $PACKAGE$ - package of the tested file. i.e org/intellij/plugins/junitgen
3. $FILENAME$ - the name of the output file.
Default output pattern is $SOURCEPATH$/test/$PACKAGE$/$FILENAME$. 
i.e c:/src/test/junitgen/org/intellij/plugins/junitgen

Using

To invoke a plugin hit Alt+Insert you will see "JUnit Test" menu in the list.

Plugins installation

  • Download the binary ZIP file (see below)
  • Unzip junitgen.zip in your <%IntelliJRoot%>/plugins directory.
As a result you should have junitgen.jar in plugins dir. and two files in resources directory.
1. junitgen.vm - velocity template
2. junitgen.properties - output configuration file.

IntelliJPluginWebForm
IntelliJPluginName: JUnitGenerator
IntelliJPluginVersion: 1.1
IntelliJPluginVendor: Alex Nazimok
IntelliJPluginBinary:
IntelliJPluginSource:
IntelliJPluginClassification: CodeHelper?
TopicClassification: IntelliJPluginPackage
TopicShortDescription: This is very simple plugin that generates JUnit test case skeleton including all the methods of tested class.
TestedOnOS: AnyOS
ShouldRunOnOS: AnyOS

Attachment: sort Action: Size: Date: Who: Comment:
junitgen-1.1.5.zip action 25374 15 Nov 2004 - 14:10 AlexNazimok Added fieldList in Velocity context.
junitgen-1.1.5-src.zip action 55226 15 Nov 2004 - 14:11 AlexNazimok Added fieldList in Velocity context.
junitgen-1.1.6.zip action 25139 06 Aug 2005 - 17:35 AlexNazimok Updates for IDEA 5
junitgen-1.1.6-src.zip action 30050 06 Aug 2005 - 17:38 AlexNazimok Updates for IDEA 5
junitgen-1.1.7.zip action 25732 02 Mar 2006 - 17:29 AlexNazimok For bean methods set and get now combined into one
junitgen-1.1.7-src.zip action 56973 02 Mar 2006 - 17:29 AlexNazimok For bean methods set and get now combined into one

e d i t a t t a c h r e f - b y d i f f s m o r e
Have ideas, requests, problems regarding this site? Send feedback.
Copyright © 2000-2003 by the contributing authors. All materials at intellij.org are the property of the contributing authors.