1

現在、ライブラリとして使用されている js ファイルを除外するように JSOver を取得しようとしています。私は以下のantスクリプトのセットを持っています

  1. JSカバーサーバーを起動する
  2. JSON レポートの実行と生成
  3. サーバーを停止する

最後に、sonarqube で使用できるように、Json ファイルを LCov に変換するシェル コマンドがあります。jscoverage.html でもカバレッジを取得しますが、web/ の下にあるすべてのファイルが含まれています。これは望ましくありません。下の画像

ここに画像の説明を入力

以下の Ant スクリプト:

    <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 ファイルを再帰的に読み取っていて、ソナーやアリからそれを防ぐことはできません。

誰でも光を当てることができますか?

4

2 に答える 2

1
<arg value="--no-instrument=/js/"/>

テスト自体を削除するには、

<arg value="--no-instrument=/test/"/>

パスは Web サーバーから見たものなので、「web」プレフィックスは次のとおりです。

<arg value="--no-instrument=web/js/"/>

効果はありません。

于 2015-03-17T08:50:13.903 に答える
0

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-17T10:45:32.633 に答える