首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JSCover -不包括覆盖率文件

JSCover -不包括覆盖率文件
EN

Stack Overflow用户
提问于 2015-03-12 11:44:56
回答 2查看 462关注 0票数 1

目前正试图使JSCover排除用作库的js文件。我有一组ant脚本,下面是

  1. 启动JSCover服务器
  2. 运行并生成Json报告
  3. 停止服务器

最后,我有一个shell命令将Json文件转换为LCov,以便我可以与sonarqube一起使用它。我也在jscoverage.html中得到了报道,但它包含了web/下的每个文件,这是我不想要的。下图

蚂蚁脚本如下:

代码语言:javascript
复制
    <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文件,而我无法阻止来自声纳或蚂蚁的这种情况。

有人能给点线索吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-03-17 10:45:32

我通过更正shell命令解决了自己的问题,该命令生成LCOV报告。

代码语言:javascript
复制
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文件所在的位置。

我希望这能帮到别人

票数 0
EN

Stack Overflow用户

发布于 2015-03-17 08:50:13

代码语言:javascript
复制
<arg value="--no-instrument=/js/"/>

应该能起作用,并且移除测试本身,

代码语言:javascript
复制
<arg value="--no-instrument=/test/"/>

路径与web服务器看到的一样,因此“web”前缀在:

代码语言:javascript
复制
<arg value="--no-instrument=web/js/"/>

没有效果。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29008888

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档