모든 단위 테스트 및 적용 범위를 실행할 준비가 된 javascript 파일이 있습니다. 그리고 스크립트는 coverage.json 파일을 생성합니다. cobertura 플러그인 (https://wiki.jenkins-ci.org/display/JENKINS/Cobertura+Plugin)을 사용하여 나는 cobertura에 적합한 xml 형식의 파일을 만드는 솔루션을 찾고있었습니다.lcov.info 또는 Jenkins VirtualEnv의 coverage.json 파일에서 cobertura.xml 파일을 생성 할 수 없습니다.
나는 VirutalEnv (https://wiki.jenkins-ci.org/display/JENKINS/ShiningPanda+Plugin)에서 모든 작업을 수행합니다!
내가이 명령 시도 : istanbul report cobertura --root $WORKSPACE/coverage/coverage.json --dir coverage/
(https://github.com/gotwarlost/istanbul)
을 다음과 같이 결과는 다음과 같습니다
13:26:09 [...]
13:26:09 210 passing (1s)
13:26:09
13:26:09 =============================================================================
13:26:09 Writing coverage object [/var/lib/jenkins/workspace/unit-tests-client-javascript/coverage/coverage.json]
13:26:09 Writing coverage reports at [/var/lib/jenkins/workspace/unit-tests-client-javascript/coverage]
13:26:09 =============================================================================
13:26:09
13:26:09 =============================== Coverage summary ===============================
13:26:09 Statements : 96.88% (279/288)
13:26:09 Branches : 86.24% (94/109), 1 ignored
13:26:09 Functions : 100% (57/57)
13:26:09 Lines : 96.88% (279/288)
13:26:09 ================================================================================
13:26:11 + istanbul report cobertura --root /var/lib/jenkins/workspace/unit-tests-client-javascript/coverage/coverage.json --dir coverage/
13:26:11 Done
13:26:11 [Cobertura] Publishing Cobertura coverage report...
13:26:11 Publishing Cobertura coverage results...
13:26:11 Cobertura coverage report found.
13:26:11 Finished: SUCCESS
그러나, 생성 된 cobertura-coverage.xml 파일이 거의 비어 있습니다!
<?xml version="1.0" ?>
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
<coverage lines-valid="0" lines-covered="0" line-rate="1" branches-valid="0" branches-covered="0" branch-rate="1" timestamp="1483968808589" complexity="0" version="0.1">
<sources>
<source>/var/lib/jenkins/workspace/unit-tests-client-javascript</source>
</sources>
<packages>
</packages>
그리고 코드 cobertura 코드 검사 도구는 아무것도 보여주지! 0 !!
나는 또한 lcov - 투 - cobertura-XML ( https://github.com/eriwen/lcov-to-cobertura-xml)를 사용했지만, 결과는 다음과 같다 : 내가 잘못 뭐하는 거지14:33:24 [...]
14:33:24 + git clone https://github.com/eriwen/lcov-to-cobertura-xml.git
14:33:24 Cloning into 'lcov-to-cobertura-xml'...
14:33:27 + pip install /var/lib/jenkins/workspace/unit-tests-client-javascript/lcov-to-cobertura-xml/.
14:33:27 Processing ./lcov-to-cobertura-xml
14:33:27 Requirement already satisfied (use --upgrade to upgrade): lcov-cobertura==1.6 from file:///var/lib/jenkins/workspace/unit-tests-client-javascript/lcov-to-cobertura-xml in /var/lib/jenkins/shiningpanda/jobs/e24105b6/virtualenvs/d41d8cd9/lib/python2.7/site-packages
14:33:27 Building wheels for collected packages: lcov-cobertura
14:33:27 Running setup.py bdist_wheel for lcov-cobertura: started
14:33:28 Running setup.py bdist_wheel for lcov-cobertura: finished with status 'done'
14:33:28 Stored in directory: /var/lib/jenkins/.cache/pip/wheels/06/91/3e/ead128a367068e0e33fd380f090030c829dff190d4099a2e3b
14:33:28 Successfully built lcov-cobertura
14:33:28 + lcov_cobertura coverage/lcov.info --base-dir /var/lib/jenkins/workspace/unit-tests-client-javascript --excludes /var/lib/jenkins/workspace/unit-tests-client-javascript/test --output coverage/coverage.xml
14:33:28 /tmp/shiningpanda2010602884229553447.sh: line 40: lcov_cobertura: command not found
14:33:28 Build step 'Virtualenv Builder' marked build as failure
14:33:28 Finished: FAILURE
? 이 문제를 해결하기 위해 너무 많은 시간을 낭비했습니다 !!! 어쩌면 coverage.json 파일을 코드 커버리지의 차트 또는 그래프 시각화로 변환 할 수있는 다른 도구를 사용해야할까요? 내가 istanbul report cobertura --root $WORKSPACE/coverage --dir $WORKSPACE
로 변경 그리고 지금은 완벽하게 작동 istanbul report cobertura --root $WORKSPACE/coverage/coverage.json --dir coverage/
: