目前正试图使JSCover排除用作库的js文件。我有一组ant脚本,下面是
最后,我有一个shell命令将Json文件转换为LCov,以便我可以与sonarqube一起使用它。我也在jscoverage.html中得到了报道,但它包含了web/下的每个文件,这是我不想要的。下图

蚂蚁脚本如下:
<target name="jstest-start">
<java jar=".../JSCover.jar" fork="true" spawn="true">
<arg value="-ws"/>
<arg value="--report-dir=coverage"/>
<arg value="--document-root=web"/>
<arg value="--port=8082"/>
<!-- Aim is to exclude folder js under web/ as it contains libraries, not source code. Currently does not work -->
<arg value="--no-instrument=web/js/"/>
<arg value="--no-instrument=js/"/>
</java>
<waitfor maxwait="5" maxwaitunit="second" checkevery="250" checkeveryunit="millisecond" timeoutproperty="failed">
<http url="http://localhost:8082/jscoverage.html"/>
</waitfor>
<fail if="failed"/>
</target>
<target name="jstest-run">
<exec dir="/usr/local/CI/phantomjs/bin/" executable="phantomjs" failonerror="true">
<arg line=".../run-jscover-qunit.js http://localhost:8082/index.html"/>
</exec>
</target>
<target name="jstest-stop">
<get src="http://localhost:8082/stop" dest="stop.txt" />
</target>
<target name="jstest" description="Run javascript tests">
<antcall target="jstest-start"/>
<antcall target="jstest-run"/>
<antcall target="jstest-stop"/>
</target>我的文件夹结构是:

最后,我的声纳独立分析设置:

因此,似乎正在发生的事情是,JSCover正在递归地读取所有js文件,而我无法阻止来自声纳或蚂蚁的这种情况。
有人能给点线索吗?
发布于 2015-03-17 10:45:32
我通过更正shell命令解决了自己的问题,该命令生成LCOV报告。
java -cp JSCover.jar jscover.report.Main --format=LCOV /usr/local/CI/jenkins/workspace/PhantomJS/coverage/phantom/ /usr/local/CI/jenkins/workspace/PhantomJS/web/在此之前,SRC-DIR和REPORT-DIR是相同的,这是我的一个错误。据我所知,SRC-DIR应该指向源文件夹,而REPORT-DIR应该指向lcov文件所在的位置。
我希望这能帮到别人
发布于 2015-03-17 08:50:13
<arg value="--no-instrument=/js/"/>应该能起作用,并且移除测试本身,
<arg value="--no-instrument=/test/"/>路径与web服务器看到的一样,因此“web”前缀在:
<arg value="--no-instrument=web/js/"/>没有效果。
https://stackoverflow.com/questions/29008888
复制相似问题