npm.io
1.0.23 • Published 1 year agoCLI

bjc

Licence
—
Version
1.0.23
Deps
7
Size
3.5 MB
Vulns
0
Weekly
0

bjc

Description

bjc is an OpenHarmony ets instrument tool.

Installation

npm install bjc

Build

Install dependencies

npm i

Build & Pack

npm run build
npm pack

Instructions

1. Usage
Usage: bjc [options] [command]

Options:
  -V, --version                output the version number
  -h, --help                   display help for command

Commands:
  report <input> [output]      parse coverage data to generate report.
  instrument <input> [output]
  install <sdk_home>
  help [command]               display help for command
2. Using in command-line-tools
  1. Download command-line-tools
    Command Line Tools

bjc is integrated into hvigor and the bjc code can be seen in the directory

${command-line-tools}\hvigor\hvigor-ohos-plugin\node_modules\@ohos\coverage\lib\src\bjc
${DevEco Studio}\tools\hvigor\hvigor-ohos-plugin\node_modules\@ohos\coverage\lib\src\bjc
  1. hvigor build Hap & instrument coverage
hvigorw -p buildMode=debug -p ohos-test-coverage=true -p coverage-mode=black -p debugLine=true clean assembleHsp assembleHap

For more details, please refer to the URL https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/ide-ui-test

3. Coverage file storage location
/data/app/el2/100/base/${bundleName}/haps/{entryModuleName}/cache/bjc_cov_xxx.json
4. Instrument ignore feature
ignore file

Add a comment to the source file // instrument ignore file or /* instrument ignore file */. after adding the comment, the file will no longer be instrumented, and the coverage report will not have the file.

ignore next

Add // instrument ignore next or /* instrument ignore next */ in front of the code block.

ignore if

Add // instrument ignore if or /* instrument ignore if */in front of the conditional expression to ignore if branch.

ignore else

Add // instrument ignore else or /* instrument ignore else */in front of the conditional expression to ignore else branch.