zoukankan      html  css  js  c++  java
  • 怎样在IDEA中使用JUnit4和JUnitGenerator V2.0自动生成测试模块

    前言----无法下载插件 请参考:https://my.oschina.net/u/2851681/blog/1789746

    解决办法:浏览器下载本地安装
    http://plugins.jetbrains.com/pluginManager/?action=download&id=org.intellij.plugins.junitgen&build=IU-162.2228.15&uuid=6a6cb9f5-4107-46d7-9b1c-d8205218a73b

    本文参考:https://www.cnblogs.com/libingbin/p/6007203.html

    maven项目对应的Output Path

    单项目
    ${SOURCEPATH}/../../test/java/${PACKAGE}/${FILENAME}
    聚合项目
    ${SOURCEPATH}/../../../../provider/src/test/java/${PACKAGE}/${FILENAME}

    junit4模板

    
    

    ########################################################################################
    ##
    ## Available variables:
    ## $entryList.methodList - List of method composites
    ## $entryList.privateMethodList - List of private method composites
    ## $entryList.fieldList - ArrayList of class scope field names
    ## $entryList.className - class name
    ## $entryList.packageName - package name
    ## $today - Todays date in MM/dd/yyyy format
    ##
    ## MethodComposite variables:
    ## $method.name - Method Name
    ## $method.signature - Full method signature in String form
    ## $method.reflectionCode - list of strings representing commented out reflection code to access method (Private Methods)
    ## $method.paramNames - List of Strings representing the method's parameters' names
    ## $method.paramClasses - List of Strings representing the method's parameters' classes
    ##
    ## You can configure the output class name using "testClass" variable below.
    ## Here are some examples:
    ## Test${entry.ClassName} - will produce TestSomeClass
    ## ${entry.className}Test - will produce SomeClassTest
    ##
    ########################################################################################
    ##
    #macro (cap $strIn)$strIn.valueOf($strIn.charAt(0)).toUpperCase()$strIn.substring(1)#end
    ## Iterate through the list and generate testcase for every entry.
    #foreach ($entry in $entryList)
    #set( $testClass="${entry.className}Test")
    ##

    package $entry.packageName; 

    import org.junit.Test;
    import org.junit.Before;
    import org.junit.After;

    
    

    /**
    * Created by auther on $today
    */
    //@RunWith(SpringJUnit4ClassRunner.class)
    //@ContextConfiguration(locations = "classpath:spring-config.xml")
    public class $testClass {

    static final Logger logger = LoggerFactory.getLogger($testClass .class);

    /**
    *
    */
    @Before
    public void before() throws Exception {

    }
    /**
    *
    */
    @After
    public void after() throws Exception {

    }

    #foreach($method in $entry.methodList)
    /**
    *
    */
    @Test
    public void test#cap(${method.name})() throws Exception {

    }

    #end

    #foreach($method in $entry.privateMethodList)
    /**
    *
    */
    @Test
    public void test#cap(${method.name})() throws Exception {

    #foreach($string in $method.reflectionCode)
    $string
    #end
    }

    #end
    }
    #end

     

     mac用户正确使用姿势(有其他方式不妨留言交流一下哈):

    目标类中全部方法,command+n 

    单个方法,选中方法command+shift+t

  • 相关阅读:
    arcgis api 3.x for js 入门开发系列八聚合效果(附源码下载)
    arcgis api 3.x for js 入门开发系列七图层控制(附源码下载)
    arcgis api 3.x for js 入门开发系列六地图分屏对比(附源码下载)
    arcgis api 3.x for js 入门开发系列五地图态势标绘(附源码下载)
    arcgis api 3.x for js 入门开发系列四地图查询(附源码下载)
    Java里面获取当前服务器的IP地址
    Flutter at Google I/O 2018
    Modbus RTU 协议使用汇总
    plsql 创建表空间、用户、赋予权限
    Oracle:ODP.NET Managed 小试牛刀
  • 原文地址:https://www.cnblogs.com/hhls/p/8822561.html
Copyright © 2011-2022 走看看