2023-09-13, Wednesday, Cloudy

新工上遇上了挫折。寫好的東西達不到標準需要別人執手尾了。雖然同事說沒關係,但反應了自己的不足。有時反省自己為何做事總是不好,為何別人有留意或想到的事情自己總是忽略。現在覺得是自己天生的思考模式問題,可能看多少書都沒用。或者自己應該更適合做地盤呢類工作,而唔係IT。

Debugging Maven test cases with Eclipse 如何在Eclipse中為Maven的test case除錯

1. Add Junit 4.7.1 dependency in project's pom files. 首先, 先加入Junit 4.7.1.

junit
junit
4.8.1
test


2. write a test case in Junit 4.7, like below: 寫一個Junit 4.7的測試用例. 例如:
package com.sml.form.restore;

import org.junit.Assert;
import org.junit.Test;

import com.sml.formrestore.SpringContextUtil;
import com.sml.formrestore.mvc.dao.product.mapper.ProductSpecMapper;
import com.sml.formrestore.mvc.dao.product.model.ProductSpec;

public class StartUpTest {

@Test
public void TestStartUpTestCase(){
// the test method must be annotated with @Test, and starts with Test, or ends with Test, TestCase
                // 用例名稱必需以Test開首,或以Test, 或TestCase結尾,
                // Write your test case here...
                //在這裏寫測試用例...
}


}

3. Finally, if you want to use Eclipse debugger to debug, you must:
最後, 如果你想以Eclipse內置的除錯工具除錯, 你需要:
   a. Right-click project -> Debug As->Debug Configuration
   b. Input "-Dmaven.surefile.debug test" in Goals
   c. Add a parameter "forkMode" with value "never"
   甲. 右按項目-> Debug As->Debug Configuration
   乙. 於Goals輸入"-Dmaven.surefile.debug test"
   丙. 加一個參數, 名稱:"forkMode", 值:"never".

參見:ref:http://stackoverflow.com/questions/12598261/maven-build-debug-in-eclipse

Moreover:
另外:
I have tested with the parameter forkCount=0 described here, but not working.
測試過參數forkCount=0, 但跑不了.
http://maven.apache.org/surefire/maven-surefire-plugin/examples/debugging.html

Comments

Popular posts from this blog

Install Apache Superset on Ubuntu 18.04

生的感覺、死的感覺

2023-03-18, Saturday, Sunny