idea+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; 

/** 
* ${entry.className} Tester. 

* @author <Authors name> 
* @since <pre>$today</pre> 
* @version 1.0 
*/ 
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class $testClass { 

@Before
public void before() throws Exception { 

@After
public void after() throws Exception { 

#foreach($method in $entry.methodList) 
/** 

* Method: $method.signature 

*/ 
@Test
public void test#cap(${method.name})() throws Exception { 
//TODO: Test goes here... 

#end 

#foreach($method in $entry.privateMethodList) 
/** 

* Method: $method.signature 

*/ 
@Test
public void test#cap(${method.name})() throws Exception { 
//TODO: Test goes here... 
#foreach($string in $method.reflectionCode) 
$string 
#end 

#end 

#end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
配置JUnit在IntelliJ IDEA中,可以按照以下步骤进行操作: 1. 首先,确保你已经在IDEA中创建了一个Java项目。 2. 接下来,点击菜单栏的"File",然后选择"Project Structure"。 3. 在弹出的窗口中,选择"Modules"选项卡,并确保你的项目模块被选中。 4. 在右侧的面板中,选择"Dependencies"选项卡,并点击左上角的"+"按钮。 5. 在弹出的菜单中,选择"Library",然后选择"JUnit"。 6. 如果你已经下载了JUnit的jar文件,可以选择"From Maven"选项,然后在搜索框中输入"junit"进行搜索,并选择合适的版本进行导入。 7. 如果你还没有下载JUnit,可以选择"New Library"选项,然后手动下载并导入JUnit的jar文件。 8. 点击"OK"按钮完成配置。 如果你遇到了配置问题,可以参考引用和引用提供的方法进行配置。如果配置不成功,还可以尝试引用提供的最暴力的解决办法,即先写测试代码并使用@Test注解,IDE会报错并提示你导入相关的JUnit环境,你只需要选择刚才下载的JUnit版本进行导入即可。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [用IDEA时的JUnit配置过程](https://blog.csdn.net/tangodope/article/details/125126483)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [详解IDEA JUnit5测试套件运行错误的问题](https://download.csdn.net/download/weixin_38629362/12744182)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值