This is the 10th day of my participation in the August Text Challenge.More challenges in August

preface

Super-jacoco is a project developed by Didi based on Jacoco secondary development. It can realize engineering code coverage statistics and support coverage statistics of full code and incremental code. It can automatically execute Jacoco dump, report and other commands, which is easy to deploy and can generate visual reports.

Super-jacoco project address: github.com/tigerge000/…

Practical steps
1. Take the code down and change the database connection information and gitlab configuration in the application.properties file. Of course, there are three sets of mysql, JDk1.8, maven3 that must be prepared before this step.Copy the code

Mysql > create tables and libraries by running mysql > create tables. Execute MVN package-dmaven.test. skip=true to generate super-Jacoco. jar in the target directory of super-Jacoco-master.Copy the code
3. Place the two JAR packages from the Jacoco directory in the super-Jacoco master directory under the User's home directory, usually /User/admin.Copy the code

Nohup java-jar super-jacoco.jar & (default port 8899) The default access path for logs and reports is 8899.Copy the code
5, to start the project to be tested, add the following command to the start item: - javaagent: / Users/admin/org jacoco. Agent - 0.8.5 - runtime. Jar = includes = *, output = tcpserver, address = 127.0.0.1 port = 6300, appe Nd =true After the service is started, functional tests can be carried out. After the tests are completed, jacoco interfaces are executed to collect coverage.Copy the code
/cov/triggerEnvCov {" uuid ":" uuid ", "type" : 1, "gitUrl" : ""," subModule ":" ", "baseVersion" : "master," "nowVersion" : "daily", "Address", "127.0.0.1", "port" : "6300"} returns: {" code ": 200," data ": null," MSG ":" success "} remarks: - javaagent: / Users/admin/org jacoco. Agent - 0.8.5 - runtime. Jar = includes = *, output = tcpserver, address = 127.0.0.1 port = 6300, appe Nd =true address=127.0.0.1,port=6300 are the same as "address":"127.0.0.1","port":"6300". Type 1 is full and type 2 is incremental. BaseVersion Original branch nowVersion Current branchCopy the code

/cov/getEnvCoverResult Call method: GET Parameter: uuid(String) Return: {" code ": 200," data ": {" coverStatus" : 1, "errMsg" : "MSG", "lineCoverage" : 100.0, "branchCoverage" : 100.0, "logFile" : "the file content","reportUrl":"http://"},"msg":"msg"}Copy the code

Matters needing attention

1. After coverage collection is started and new code is pulled, it will take some time to compile the project. Wait for 1-2 minutes patiently.

2. There are some minor flaws in this code, it is not suitable for all types of projects, such as multiple COM projects, but only one project with POM file, cyclic module fetch error.

3. Uuid is a unique key that cannot be repeated.